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:
कारतोफ्फेलस्क्रिप्ट™
2023-03-09 14:42:13 +01:00
committed by GitHub
parent 493f7a1c92
commit 356e916194
19 changed files with 356 additions and 389 deletions

View 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);
};