Skip to content

Instantly share code, notes, and snippets.

View remojansen's full-sized avatar

Remo H. Jansen remojansen

View GitHub Profile
@remojansen
remojansen / 1_question.md
Last active December 10, 2025 22:05
temp.md

This middleware is used by all microservices. When the microservice is the auth service, it essentially invokes itself. When the microservice is not the auth service, it makes a remote call to the auth service.

Is this a good approach, or should I change the logic within the middleware so that the auth service avoids making a remote call to itself? Alternatively, should I use two different middlewares?

import type { ExpressMiddleware } from "@inversifyjs/http-express";
import type * as express from "express";
import { inject, injectable } from "inversify";
import {
	type RemoteServiceClient,
@remojansen
remojansen / lib.ts
Last active August 15, 2024 13:26
"attempt" TypeScript "try" utility
class Result<T, E = Error> {
constructor(
private v: T | undefined,
private e: E | undefined
) {}
onSuccess(cb: (v: T) => void) {
if (this.v !== undefined) {
cb(this.v as T);
}
}
@remojansen
remojansen / keybase.md
Created February 17, 2017 00:14
keybase.md

Keybase proof

I hereby claim:

  • I am remojansen on github.
  • I am remojansen (https://keybase.io/remojansen) on keybase.
  • I have a public key whose fingerprint is 95CF 4000 58A6 7EBF D965 2C32 C2E7 7CC5 4C37 06E7

To claim this, I am signing this object:

@remojansen
remojansen / class_decorator.ts
Last active July 30, 2025 05:53
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}