routup 1.0.1 → 1.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.
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import zod from 'zod';
|
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
5
|
import { Stats, stat, createReadStream } from 'node:fs';
|
|
6
6
|
import { merge, hasOwnProperty, distinctArray } from 'smob';
|
|
7
|
-
import
|
|
7
|
+
import { compile, all } from 'proxy-addr';
|
|
8
8
|
import { getType, get } from 'mime-explorer';
|
|
9
9
|
import { GatewayTimeoutErrorOptions, BadRequestError } from '@ebec/http';
|
|
10
10
|
import Negotiator from 'negotiator';
|
|
@@ -96,7 +96,7 @@ function buildTrustProxyFn(input) {
|
|
|
96
96
|
if (typeof input === 'string') {
|
|
97
97
|
input = input.split(',').map((value)=>value.trim());
|
|
98
98
|
}
|
|
99
|
-
return
|
|
99
|
+
return compile(input || []);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
function isInstance(input, name) {
|
|
@@ -573,7 +573,8 @@ function getRequestIP(req, options) {
|
|
|
573
573
|
const config = useConfig();
|
|
574
574
|
trustProxy = config.get('trustProxy');
|
|
575
575
|
}
|
|
576
|
-
|
|
576
|
+
const addrs = all(req, trustProxy);
|
|
577
|
+
return addrs[addrs.length - 1];
|
|
577
578
|
}
|
|
578
579
|
|
|
579
580
|
const ReqMountPathSymbol = Symbol.for('ReqMountPath');
|
|
@@ -991,7 +992,7 @@ function sendFile(res, filePath, fn) {
|
|
|
991
992
|
}
|
|
992
993
|
|
|
993
994
|
function sendFormat(res, input) {
|
|
994
|
-
const { default: formatDefault
|
|
995
|
+
const { default: formatDefault, ...formats } = input;
|
|
995
996
|
const contentTypes = Object.keys(formats);
|
|
996
997
|
const contentType = getRequestAcceptableContentType(res.req, contentTypes);
|
|
997
998
|
if (contentType) {
|