@thisisagile/easy-express
Version:
Straightforward library for building domain-driven microservice architectures
17 lines (12 loc) • 473 B
text/typescript
import { createNamespace } from 'cls-hooked';
import { BaseRequestContext } from '@thisisagile/easy';
export class NamespaceContext extends BaseRequestContext {
protected readonly namespace = createNamespace('context');
public get<T>(key: string): T {
return this.namespace.get(key) as T;
}
public set<T>(key: string, value: T): T {
return this.namespace.set(key, value);
}
public readonly create = (f: () => void): void => this.namespace.run(f);
}