hola-server 0.4.8 → 0.4.10
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/http/express.js +18 -3
- package/package.json +1 -1
package/http/express.js
CHANGED
|
@@ -11,6 +11,18 @@ const { asyncLocalStorage, set_context_value } = require('./context');
|
|
|
11
11
|
const app = express();
|
|
12
12
|
let server_initialized = false;
|
|
13
13
|
|
|
14
|
+
const is_excluded_url = (server, req) => {
|
|
15
|
+
const exclude_urls = server.exclude_urls;
|
|
16
|
+
for (let i = 0; i < exclude_urls.length; i++) {
|
|
17
|
+
const re = new RegExp(exclude_urls[i], "gim");
|
|
18
|
+
if (re.test(req.originalUrl)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
const init_express_server = (base_dir, callback) => {
|
|
15
27
|
if (server_initialized === true) {
|
|
16
28
|
return app;
|
|
@@ -25,9 +37,7 @@ const init_express_server = (base_dir, callback) => {
|
|
|
25
37
|
init_session(app);
|
|
26
38
|
|
|
27
39
|
app.use((req, res, next) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (server.check_user && !exclude_urls.includes(req.originalUrl)) {
|
|
40
|
+
if (server.check_user && !is_excluded_url(server, req)) {
|
|
31
41
|
const user_id = get_session_userid(req);
|
|
32
42
|
if (user_id == null) {
|
|
33
43
|
res.json({ code: NO_SESSION, err: "no session found" });
|
|
@@ -59,3 +69,8 @@ const init_express_server = (base_dir, callback) => {
|
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
module.exports = { init_express_server };
|
|
72
|
+
|
|
73
|
+
const str = "/monitor/635c7e6aecf2f40bf70feca9";
|
|
74
|
+
const exclude_urls = ["/monitor/.*?/"];
|
|
75
|
+
|
|
76
|
+
|