1- import {
2- PATH_METADATA ,
3- PATH_PREFIX_METADATA ,
4- SCOPE_OPTIONS_METADATA ,
5- } from '../../constants' ;
1+ import { PATH_METADATA , SCOPE_OPTIONS_METADATA } from '../../constants' ;
62import { isString , isUndefined } from '../../utils/shared.utils' ;
73import { ScopeOptions } from '../../interfaces/scope-options.interface' ;
84
@@ -13,22 +9,12 @@ import { ScopeOptions } from '../../interfaces/scope-options.interface';
139 */
1410export interface ControllerOptions extends ScopeOptions {
1511 /**
16- * Specifies an optional `route path prefix`. The prefix is pre-pended to the
12+ * Specifies an optional `route path prefix`. The prefix is pre-pended to the
1713 * path specified in any request decorator in the class.
1814 *
1915 * @see [Routing](https://docs.nestjs.com/controllers#routing)
2016 */
2117 path ?: string ;
22-
23- /**
24- * Specifies an optional setting for enabling/disabling the use of app's
25- * GlobalPrefix. In other words, a switch to remove the prefix set using
26- * `setGlobalPrefix()` only for this controller.
27- *
28- * @see [Routing](https://docs.nestjs.com/controllers#routing)
29- * @see [Global path prefix](https://docs.nestjs.com/faq/global-prefix)
30- */
31- useGlobalPrefix ?: boolean ;
3218}
3319
3420/**
@@ -127,10 +113,8 @@ export function Controller(options: ControllerOptions): ClassDecorator;
127113 * - `scope` - symbol that determines the lifetime of a Controller instance.
128114 * [See Scope](https://docs.nestjs.com/fundamentals/injection-scopes#usage) for
129115 * more details.
130- * - `path ` - string that defines a `route path prefix`. The prefix
116+ * - `prefix ` - string that defines a `route path prefix`. The prefix
131117 * is pre-pended to the path specified in any request decorator in the class.
132- * - `useGlobalPrefix` - a boolean value that enables/disables the setting done
133- * using `setGlobalPrefix()`.
134118 *
135119 * @see [Routing](https://docs.nestjs.com/controllers#routing)
136120 * @see [Controllers](https://docs.nestjs.com/controllers)
@@ -143,22 +127,14 @@ export function Controller(
143127 prefixOrOptions ?: string | ControllerOptions ,
144128) : ClassDecorator {
145129 const defaultPath = '/' ;
146- const defaultUseGlobalPrefix = true ;
147- const [ path , useGlobalPrefix , scopeOptions ] = isUndefined ( prefixOrOptions )
148- ? [ defaultPath , defaultUseGlobalPrefix , undefined ]
130+ const [ path , scopeOptions ] = isUndefined ( prefixOrOptions )
131+ ? [ defaultPath , undefined ]
149132 : isString ( prefixOrOptions )
150- ? [ prefixOrOptions , defaultUseGlobalPrefix , undefined ]
151- : [
152- prefixOrOptions . path || defaultPath ,
153- ! isUndefined ( prefixOrOptions )
154- ? Boolean ( prefixOrOptions . useGlobalPrefix )
155- : defaultUseGlobalPrefix ,
156- { scope : prefixOrOptions . scope } ,
157- ] ;
133+ ? [ prefixOrOptions , undefined ]
134+ : [ prefixOrOptions . path || defaultPath , { scope : prefixOrOptions . scope } ] ;
158135
159136 return ( target : object ) => {
160137 Reflect . defineMetadata ( PATH_METADATA , path , target ) ;
161138 Reflect . defineMetadata ( SCOPE_OPTIONS_METADATA , scopeOptions , target ) ;
162- Reflect . defineMetadata ( PATH_PREFIX_METADATA , useGlobalPrefix , target ) ;
163139 } ;
164140}
0 commit comments