Typescript Decorators
function log(target: any, property: string, descriptor: PropertyDescriptor) {
let method = descriptor.value;
descriptor.value = function() {
console.warn(`[RUNNING]: ${property}`);
method.apply(this, arguments);
}
}
class Handlers {
@log
static handler(_: any, res: any): void {
res.send("Hello ts-node!");
}
}
{
"compilerOptions": {
"experimentalDecorators": true
}
}