@nestjs/platform-express 12.0.1 → 12.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,6 +59,7 @@ export declare class ExpressAdapter extends AbstractHttpAdapter<http.Server | ht
|
|
|
59
59
|
isRouteOrderSensitive(): boolean;
|
|
60
60
|
applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute;
|
|
61
61
|
mapException(error: unknown): unknown;
|
|
62
|
+
private normalizePrefix;
|
|
62
63
|
private trackOpenConnections;
|
|
63
64
|
private closeOpenConnections;
|
|
64
65
|
private isMiddlewareApplied;
|
|
@@ -5,7 +5,7 @@ import * as http from 'http';
|
|
|
5
5
|
import * as https from 'https';
|
|
6
6
|
import { pathToRegexp } from 'path-to-regexp';
|
|
7
7
|
import { getBodyParserOptions } from './utils/get-body-parser-options.util.js';
|
|
8
|
-
import { isFunction, isNil, isObject, isString, isUndefined, } from '@nestjs/common/internal';
|
|
8
|
+
import { addLeadingSlash, isFunction, isNil, isObject, isString, isUndefined, stripEndSlash, } from '@nestjs/common/internal';
|
|
9
9
|
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
10
10
|
import { RouterMethodFactory, LegacyRouteConverter, } from '@nestjs/core/internal';
|
|
11
11
|
/**
|
|
@@ -80,10 +80,11 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
80
80
|
return response.redirect(statusCode, url);
|
|
81
81
|
}
|
|
82
82
|
setErrorHandler(handler, prefix) {
|
|
83
|
-
|
|
83
|
+
const normalizedPrefix = this.normalizePrefix(prefix);
|
|
84
|
+
if (normalizedPrefix) {
|
|
84
85
|
const router = express.Router();
|
|
85
86
|
router.use(handler);
|
|
86
|
-
this.use(
|
|
87
|
+
this.use(normalizedPrefix, router);
|
|
87
88
|
}
|
|
88
89
|
// Always mount the error handler at the root as well, so routes living
|
|
89
90
|
// outside the global prefix (e.g. "setGlobalPrefix" exclusions or
|
|
@@ -91,11 +92,12 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
91
92
|
return this.use(handler);
|
|
92
93
|
}
|
|
93
94
|
setNotFoundHandler(handler, prefix) {
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
const normalizedPrefix = this.normalizePrefix(prefix);
|
|
96
|
+
if (normalizedPrefix) {
|
|
97
|
+
this.registeredPrefixes.add(normalizedPrefix);
|
|
96
98
|
const router = express.Router();
|
|
97
99
|
router.all('*path', handler);
|
|
98
|
-
return this.use(
|
|
100
|
+
return this.use(normalizedPrefix, router);
|
|
99
101
|
}
|
|
100
102
|
return this.use((req, res, next) => {
|
|
101
103
|
// When multiple apps share this adapter, a non-prefixed app's 404
|
|
@@ -376,6 +378,9 @@ export class ExpressAdapter extends AbstractHttpAdapter {
|
|
|
376
378
|
return error;
|
|
377
379
|
}
|
|
378
380
|
}
|
|
381
|
+
normalizePrefix(prefix) {
|
|
382
|
+
return stripEndSlash(addLeadingSlash(prefix));
|
|
383
|
+
}
|
|
379
384
|
trackOpenConnections() {
|
|
380
385
|
this.httpServer.on('connection', (socket) => {
|
|
381
386
|
this.openConnections.add(socket);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/platform-express",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.3",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"cors": "2.8.6",
|
|
29
29
|
"express": "5.2.1",
|
|
30
|
-
"multer": "2.
|
|
30
|
+
"multer": "2.4.0",
|
|
31
31
|
"path-to-regexp": "8.4.2",
|
|
32
32
|
"tslib": "2.8.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@nestjs/common": "12.0.
|
|
36
|
-
"@nestjs/core": "12.0.
|
|
35
|
+
"@nestjs/common": "12.0.3",
|
|
36
|
+
"@nestjs/core": "12.0.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@nestjs/common": "^12.0.0",
|
|
40
40
|
"@nestjs/core": "^12.0.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "14151790e1abe870abc3bbf00f88786fc3ebe509"
|
|
43
43
|
}
|