@villedemontreal/correlation-id
Version:
Express middleware to set a correlation in Express. The correlation id will be consistent across async calls within the handling of a request.
29 lines (25 loc) • 673 B
text/typescript
import { ILogger } from '@villedemontreal/logger';
/**
* Http Client Config
*/
export class Configs {
private loggerCreatorVar: (name: string) => ILogger;
/**
* Sets the Logger creator.
*/
public setLoggerCreator(loggerCreator: (name: string) => ILogger) {
this.loggerCreatorVar = loggerCreator;
}
/**
* The Logger creator
*/
get loggerCreator(): (name: string) => ILogger {
if (!this.loggerCreatorVar) {
throw new Error(
`The Logger Creator HAS to be set as a configuration! Please call the init(...) fonction first.`,
);
}
return this.loggerCreatorVar;
}
}
export const configs: Configs = new Configs();