File tree 4 files changed +23
-16
lines changed
platform-express/adapters
4 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -102,4 +102,5 @@ export interface HttpServer<
102
102
version : VersionValue ,
103
103
versioningOptions : VersioningOptions ,
104
104
) : ( req : TRequest , res : TResponse , next : ( ) => void ) => Function ;
105
+ normalizePath ?( path : string ) : string ;
105
106
}
Original file line number Diff line number Diff line change @@ -143,6 +143,10 @@ export abstract class AbstractHttpAdapter<
143
143
return this . instance as T ;
144
144
}
145
145
146
+ public normalizePath ( path : string ) : string {
147
+ return path ;
148
+ }
149
+
146
150
abstract close ( ) ;
147
151
abstract initHttpServer ( options : NestApplicationOptions ) ;
148
152
abstract useStaticAssets ( ...args : any [ ] ) ;
@@ -158,11 +162,7 @@ export abstract class AbstractHttpAdapter<
158
162
abstract setErrorHandler ( handler : Function , prefix ?: string ) ;
159
163
abstract setNotFoundHandler ( handler : Function , prefix ?: string ) ;
160
164
abstract isHeadersSent ( response : any ) ;
161
- // TODO remove optional signature (v11)
162
- abstract getHeader ?( response : any , name : string ) ;
163
165
abstract setHeader ( response : any , name : string , value : string ) ;
164
- // TODO remove optional signature (v11)
165
- abstract appendHeader ?( response : any , name : string , value : string ) ;
166
166
abstract registerParserMiddleware ( prefix ?: string , rawBody ?: boolean ) ;
167
167
abstract enableCors (
168
168
options : CorsOptions | CorsOptionsDelegate < TRequest > ,
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ import { MetadataScanner } from '../metadata-scanner';
39
39
import { PipesConsumer , PipesContextCreator } from '../pipes' ;
40
40
import { ExceptionsFilter } from './interfaces/exceptions-filter.interface' ;
41
41
import { RoutePathMetadata } from './interfaces/route-path-metadata.interface' ;
42
- import { LegacyRouteConverter } from './legacy-route-converter' ;
43
42
import { PathsExplorer } from './paths-explorer' ;
44
43
import { REQUEST_CONTEXT_ID } from './request/request-constants' ;
45
44
import { RouteParamsFactory } from './route-params-factory' ;
@@ -232,15 +231,10 @@ export class RouterExplorer {
232
231
} ;
233
232
234
233
this . copyMetadataToCallback ( targetCallback , routeHandler ) ;
235
- try {
236
- const convertedPath = LegacyRouteConverter . tryConvert ( path ) ;
237
- routerMethodRef ( convertedPath , routeHandler ) ;
238
- } catch ( e ) {
239
- if ( e instanceof TypeError ) {
240
- LegacyRouteConverter . printError ( path ) ;
241
- }
242
- throw e ;
243
- }
234
+ const normalizedPath = router . normalizePath
235
+ ? router . normalizePath ( path )
236
+ : path ;
237
+ routerMethodRef ( normalizedPath , routeHandler ) ;
244
238
245
239
this . graphInspector . insertEntrypointDefinition < HttpEntrypointMetadata > (
246
240
entrypointDefinition ,
Original file line number Diff line number Diff line change @@ -144,18 +144,30 @@ export class ExpressAdapter extends AbstractHttpAdapter<
144
144
return response . headersSent ;
145
145
}
146
146
147
- public getHeader ? ( response : any , name : string ) {
147
+ public getHeader ( response : any , name : string ) {
148
148
return response . get ( name ) ;
149
149
}
150
150
151
151
public setHeader ( response : any , name : string , value : string ) {
152
152
return response . set ( name , value ) ;
153
153
}
154
154
155
- public appendHeader ? ( response : any , name : string , value : string ) {
155
+ public appendHeader ( response : any , name : string , value : string ) {
156
156
return response . append ( name , value ) ;
157
157
}
158
158
159
+ public normalizePath ( path : string ) : string {
160
+ try {
161
+ const convertedPath = LegacyRouteConverter . tryConvert ( path ) ;
162
+ return convertedPath ;
163
+ } catch ( e ) {
164
+ if ( e instanceof TypeError ) {
165
+ LegacyRouteConverter . printError ( path ) ;
166
+ }
167
+ throw e ;
168
+ }
169
+ }
170
+
159
171
public listen ( port : string | number , callback ?: ( ) => void ) : Server ;
160
172
public listen (
161
173
port : string | number ,
You can’t perform that action at this time.
0 commit comments