( prefixOrOptions?: string | string[] | ControllerOptions, )
| 149 | * @publicApi |
| 150 | */ |
| 151 | export function Controller( |
| 152 | prefixOrOptions?: string | string[] | ControllerOptions, |
| 153 | ): ClassDecorator { |
| 154 | const defaultPath = '/'; |
| 155 | |
| 156 | const [path, host, scopeOptions, versionOptions] = isUndefined( |
| 157 | prefixOrOptions, |
| 158 | ) |
| 159 | ? [defaultPath, undefined, undefined, undefined] |
| 160 | : isString(prefixOrOptions) || Array.isArray(prefixOrOptions) |
| 161 | ? [prefixOrOptions, undefined, undefined, undefined] |
| 162 | : [ |
| 163 | prefixOrOptions.path || defaultPath, |
| 164 | prefixOrOptions.host, |
| 165 | { scope: prefixOrOptions.scope, durable: prefixOrOptions.durable }, |
| 166 | Array.isArray(prefixOrOptions.version) |
| 167 | ? Array.from(new Set(prefixOrOptions.version)) |
| 168 | : prefixOrOptions.version, |
| 169 | ]; |
| 170 | |
| 171 | return (target: object) => { |
| 172 | Reflect.defineMetadata(CONTROLLER_WATERMARK, true, target); |
| 173 | Reflect.defineMetadata(PATH_METADATA, path, target); |
| 174 | Reflect.defineMetadata(HOST_METADATA, host, target); |
| 175 | Reflect.defineMetadata(SCOPE_OPTIONS_METADATA, scopeOptions, target); |
| 176 | Reflect.defineMetadata(VERSION_METADATA, versionOptions, target); |
| 177 | }; |
| 178 | } |
no test coverage detected