huxy-server 1.0.11 → 1.1.0
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/package.json +2 -2
- package/src/index.js +24 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huxy-server",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "一个精炼、高性能的 Express.js 服务器模板,为现代 Node.js 应用程序设计,提供灵活的功能和最佳实践。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./src/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"http-proxy-middleware": "^3.0.5",
|
|
39
|
-
"huxy-node-server": "^1.0.
|
|
39
|
+
"huxy-node-server": "^1.0.8",
|
|
40
40
|
"jsonwebtoken": "^9.0.3"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
package/src/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startServer as U,
|
|
3
3
|
startStatic as X,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
resolvePath as le,
|
|
4
|
+
createLogger as se,
|
|
5
|
+
dateTime as oe,
|
|
6
|
+
localIPs as ae,
|
|
7
|
+
nodeArgs as ne,
|
|
8
|
+
getEnvConfig as ie,
|
|
9
|
+
checkPort as pe,
|
|
10
|
+
getDirName as ce,
|
|
11
|
+
resolvePath as ue,
|
|
13
12
|
} from 'huxy-node-server';
|
|
14
13
|
import {createProxyMiddleware as k, fixRequestBody as O} from 'http-proxy-middleware';
|
|
15
14
|
import {dateTime as W} from 'huxy-node-server';
|
|
@@ -54,8 +53,8 @@ var R =
|
|
|
54
53
|
let n = e.headers,
|
|
55
54
|
p = n['x-huxy-auth'] || n['x-api-key'] || n.authorization?.split('Bearer ')[1];
|
|
56
55
|
if ((p && p === s) || i.includes(p)) return o();
|
|
57
|
-
let {secret: u, expiresIn:
|
|
58
|
-
m({secret: u, expiresIn:
|
|
56
|
+
let {secret: u, expiresIn: g, algorithm: j, issuer: H} = r;
|
|
57
|
+
m({secret: u, expiresIn: g, algorithm: j, issuer: H})(e, t, o);
|
|
59
58
|
},
|
|
60
59
|
w = R;
|
|
61
60
|
var E = ['origin', 'referer', 'x-forwarded-for', 'x-real-ip', 'cf-connecting-ip', 'cf-ipcountry', 'cf-ray', 'x-huxy-auth'],
|
|
@@ -83,7 +82,7 @@ var c = (r, e = '/') => {
|
|
|
83
82
|
i.status(200).json(t);
|
|
84
83
|
}));
|
|
85
84
|
},
|
|
86
|
-
|
|
85
|
+
T = 0,
|
|
87
86
|
B = ({target: r = 'http://', prefix: e, withPrefix: t, preserve: o = !0, ...i} = {}) => ({
|
|
88
87
|
target: r,
|
|
89
88
|
changeOrigin: !0,
|
|
@@ -94,7 +93,7 @@ var c = (r, e = '/') => {
|
|
|
94
93
|
!o && P(a.headers);
|
|
95
94
|
},
|
|
96
95
|
error: (a, s, n) => {
|
|
97
|
-
(
|
|
96
|
+
(T || ((T = 1), s.log.error({err: a}, '\u4EE3\u7406\u9519\u8BEF')), n.headersSent || n.status(502).json({error: '\u7F51\u5173\u9519\u8BEF'}));
|
|
98
97
|
},
|
|
99
98
|
},
|
|
100
99
|
...i,
|
|
@@ -130,26 +129,25 @@ var _ = (r, e) =>
|
|
|
130
129
|
let s = l(o, t, a);
|
|
131
130
|
(await e?.(t, o, i, a), s && c(o, t.apiPrefix));
|
|
132
131
|
}),
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
de = _,
|
|
133
|
+
me = (r, e) =>
|
|
135
134
|
X({...h, ...r}, async (t, o, i, a) => {
|
|
136
135
|
let s = l(o, t, a);
|
|
137
136
|
(await e?.(t, o, i, a), c(o, t.apiPrefix), s && c(o, t.apiPrefix));
|
|
138
137
|
});
|
|
139
138
|
export {
|
|
140
139
|
l as appProxy,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
le as resolvePath,
|
|
140
|
+
pe as checkPort,
|
|
141
|
+
se as createLogger,
|
|
142
|
+
oe as dateTime,
|
|
143
|
+
de as default,
|
|
144
|
+
ce as getDirName,
|
|
145
|
+
ie as getEnvConfig,
|
|
146
|
+
ae as localIPs,
|
|
147
|
+
ne as nodeArgs,
|
|
148
|
+
ue as resolvePath,
|
|
151
149
|
_ as startApp,
|
|
152
150
|
U as startServer,
|
|
153
151
|
X as startStatic,
|
|
154
|
-
|
|
152
|
+
me as startStaticApp,
|
|
155
153
|
};
|