hola-server 0.4.8 → 0.4.9

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.
Files changed (2) hide show
  1. package/http/express.js +26 -11
  2. package/package.json +1 -1
package/http/express.js CHANGED
@@ -25,17 +25,27 @@ const init_express_server = (base_dir, callback) => {
25
25
  init_session(app);
26
26
 
27
27
  app.use((req, res, next) => {
28
- const exclude_urls = server.exclude_urls;
29
-
30
- if (server.check_user && !exclude_urls.includes(req.originalUrl)) {
31
- const user_id = get_session_userid(req);
32
- if (user_id == null) {
33
- res.json({ code: NO_SESSION, err: "no session found" });
34
- } else {
35
- asyncLocalStorage.run({}, () => {
36
- set_context_value("req", req);
37
- next();
38
- });
28
+ if (server.check_user) {
29
+ const exclude_urls = server.exclude_urls;
30
+ let excluded = false;
31
+ for (let i = 0; i < exclude_urls.length; i++) {
32
+ const re = new RegExp(exclude_urls[i], "gim");
33
+ if (re.test(req.originalUrl)) {
34
+ excluded = true;
35
+ break;
36
+ }
37
+ }
38
+
39
+ if (!excluded) {
40
+ const user_id = get_session_userid(req);
41
+ if (user_id == null) {
42
+ res.json({ code: NO_SESSION, err: "no session found" });
43
+ } else {
44
+ asyncLocalStorage.run({}, () => {
45
+ set_context_value("req", req);
46
+ next();
47
+ });
48
+ }
39
49
  }
40
50
  } else {
41
51
  asyncLocalStorage.run({}, () => {
@@ -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
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hola-server",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "a meta programming framework used to build nodejs restful api",
5
5
  "main": "index.js",
6
6
  "scripts": {