nestjs-cls
Version:
A continuation-local storage module compatible with NestJS's dependency injection.
45 lines • 1.46 kB
TypeScript
import { InjectionToken, Provider } from '@nestjs/common';
import { ClsPlugin, ClsPluginHooks } from './cls-plugin.interface';
/**
* Extend this class to create a new ClsPlugin
*
* It contains the basic structure for a plugin, including
* some helper methods for common operations.
*/
export declare abstract class ClsPluginBase implements ClsPlugin {
readonly name: string;
imports: any[];
providers: Provider[];
exports: any[];
/**
* @param name {@link ClsPlugin.name}
*/
constructor(name: string);
protected get hooksProviderToken(): string;
/**
* Register the plugin hooks provider
*
* This is a shorthand for manually registering a provider
* that returns the plugin hooks object provided under
* the `hooksProviderToken` token.
*
* @example
* ```
* this.registerHooks({
* inject: [OPTIONS],
* useFactory: (options: PluginOptions<any>): ClsPluginHooks => ({
* afterSetup: (cls: ClsService) => {
* cls.set('some-key', options.pluginData);
* }
* })
* })
* ```
*/
protected registerHooks(opts: {
inject?: InjectionToken<any>[];
useFactory: (...args: any[]) => ClsPluginHooks;
}): void;
}
export declare function getPluginHooksToken(name: string): string;
export declare function isPluginHooksToken(token: string | symbol): boolean;
//# sourceMappingURL=cls-plugin-base.d.ts.map