nestjs-logtime-decorator
Version:
Typescript decorator to log the duration of a method, for NestJs.
23 lines (22 loc) • 898 B
TypeScript
export type ContextSource = 'Request' | 'Response';
type MeasureTimeContext = {
from: ContextSource;
key: string;
}[];
/**
* Decorator to log the time an async method takes to execute.
* Only work on methods of a class.
* Always place it AFTER the @Get, @Post, @Put, @Delete, etc. decorators.
*/
export declare function MeasureTimeAsync(options?: {
context: MeasureTimeContext;
}): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: any[]) => Promise<any>>) => void;
/**
* Decorator to log the time a sync method takes to execute.
* Only work on methods of a class.
* Always place it AFTER the @Get, @Post, @Put, @Delete, etc. decorators.
*/
export declare function MeasureTime(options?: {
context: MeasureTimeContext;
}): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<(...params: any[]) => any>) => void;
export {};