Files
Automata/packages/cli/src/decorators/RestController.ts
कारतोफ्फेलस्क्रिप्ट™ 3b70330ff6 refactor(core): Auto-register controllers at startup (no-changelog) (#9781)
2024-06-19 09:57:40 +02:00

13 lines
442 B
TypeScript

import { Service } from 'typedi';
import { getControllerMetadata } from './controller.registry';
import type { Controller } from './types';
export const RestController =
(basePath: `/${string}` = '/'): ClassDecorator =>
(target) => {
const metadata = getControllerMetadata(target as unknown as Controller);
metadata.basePath = basePath;
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return Service()(target);
};