refactor(core): Convert more routes to use the decorator pattern (no-changelog) (#5611)
* move nodeTypes api to a controller class * move tags api to a controller class * move LDAP routes to a controller class * move nodes routes to a controller class
This commit is contained in:
committed by
GitHub
parent
493f7a1c92
commit
356e916194
11
packages/cli/src/decorators/Middleware.ts
Normal file
11
packages/cli/src/decorators/Middleware.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { CONTROLLER_MIDDLEWARES } from './constants';
|
||||
import type { MiddlewareMetadata } from './types';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const Middleware = (): MethodDecorator => (target, handlerName) => {
|
||||
const controllerClass = target.constructor;
|
||||
const middlewares = (Reflect.getMetadata(CONTROLLER_MIDDLEWARES, controllerClass) ??
|
||||
[]) as MiddlewareMetadata[];
|
||||
middlewares.push({ handlerName: String(handlerName) });
|
||||
Reflect.defineMetadata(CONTROLLER_MIDDLEWARES, middlewares, controllerClass);
|
||||
};
|
||||
Reference in New Issue
Block a user