MCPcopy
hub / github.com/nestjs/nest / Controller

Function Controller

packages/common/decorators/core/controller.decorator.ts:151–178  ·  view source on GitHub ↗
(
  prefixOrOptions?: string | string[] | ControllerOptions,
)

Source from the content-addressed store, hash-verified

149 * @publicApi
150 */
151export 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}

Callers 15

app.controller.tsFile · 0.90
TestControllerClass · 0.90
TestRouteClass · 0.90
VersionedControllerClass · 0.90
BasicControllerClass · 0.90
BaseControllerClass · 0.90

Calls 2

isUndefinedFunction · 0.90
isStringFunction · 0.90

Tested by

no test coverage detected