UNPKG

kobp

Version:
36 lines (35 loc) 1.35 kB
import { KobpServiceContext } from '../context'; declare type RequestContextCreator<O extends any> = new (context: any) => O; /** * Marking any class to be available when resource is being created. * * - Automatically register to `RequestContextCreator` * * Once registered the class will automaticall enabled by the `keyName` provided. * which can be accessed through: * * `RequestRoomProvider.shared.currentInstance(keyName or classConstructor)` */ export declare function RequestContextEnabled(keyName: string): (constructor: RequestContextCreator<any>) => void; export declare class KobpRequestRoom { private static counter; readonly id: number; private data; constructor(context: KobpServiceContext); get<T>(key: string): T; set<T>(key: string, data: T): void; free(): void; } /** * A factory for `KobpRequestRoom` */ export declare class RequestRoomProvider { private static _instance?; static get shared(): RequestRoomProvider; private constructor(); createAsync(_ctx: KobpServiceContext, next: (...args: any[]) => Promise<KobpRequestRoom>): Promise<KobpRequestRoom>; current(): KobpRequestRoom | undefined; static instanceOf<O>(keyOrCnstr: string | RequestContextCreator<O>): O | undefined; currentInstance<O>(key: string | RequestContextCreator<O>): O | undefined; } export {};