import { MetaKey } from '../consts' ; import { RequestHandler , RouterOptions } from 'express' ; const metaKey = MetaKey . controller ; export interface ControllerMeta { path : string ; middlewares : RequestHandler [ ] ; routerOptions : RouterOptions ; } export function getControllerMeta ( ControllerConstructor ) { return Reflect . getMetadata ( metaKey , ControllerConstructor ) ; } export function setControllerMeta ( ControllerConstructor , meta ) { Reflect . defineMetadata ( metaKey , meta , ControllerConstructor ) ; } export function controller ( path , middlewares = [ ] , routerOptions = { } ) { return function controllerDecorator ( target ) { const meta = { path , middlewares , routerOptions } ; setControllerMeta ( target , meta ) ; } ; }