I am looking for a way to get the file path of my original function inside it's decorator without passing it by a function parameter, which is located in a different (some common) directory, since this decorator is used for many other functions. Any idea? Thanks!
// decorator in a different folder
export const SomeDecoratorFunction = () => (target, key, descriptor) => {
const originalFunction = descriptor.value;
descriptor.value = function (this) {
// Get file path of originalFunction
return originalFunction.apply(this, arguments);
};
return descriptor;
};
// original function
@SomeDecoratorFunction()
public async someFunction(req: Request, res: Response): Promise<void> {
// some code
}