express.io.js 1.0.1248 → 1.0.1611

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.
@@ -20,6 +20,7 @@ class express {
20
20
  this.host = this.config.host || "0.0.0.0";
21
21
  this.port = this.config.port || process.env.PORT || 3000;
22
22
  this.serve = this.config.static || {dotfiles: "ignore"}
23
+ Event.proto (this);
23
24
  }
24
25
  static (path = "public", option) {
25
26
  var serve = option || this.serve;
@@ -28,11 +29,12 @@ class express {
28
29
  }
29
30
  setup (context) {
30
31
  var io = function (app) {
31
- return function (r, respond, next) {
32
+ return async function (r, respond, next) {
32
33
  var http_d = {request: r, response: respond}
33
34
  var {request, response} = express.io (app, http_d);
34
35
  app.__ = {request, response}
35
- express.setup (app.__.request, app.__.response, next, http_d);
36
+ await express.setup.call (app, app.__.request, app.__.response);
37
+ express.security.call (app, app.__.request, app.__.response);
36
38
  context (app.__.request, app.__.response, next, http_d);
37
39
  }
38
40
  }
@@ -41,12 +43,7 @@ class express {
41
43
  }
42
44
  io (app, context) {
43
45
  return function (request, response, next) {
44
- if (app.__.request.error.length) {
45
- if (app.__.request.error.includes ("forbidden")) app.__.response.error.forbidden ();
46
- else if (app.__.request.error.includes ("found")) app.__.response.error.found ();
47
- else app.__.response.error ();
48
- }
49
- else context (app.__.request, app.__.response, next, {request, response});
46
+ context (app.__.request, app.__.response, next, {request, response});
50
47
  }
51
48
  }
52
49
  use (... context) {
@@ -101,6 +98,10 @@ express.request = function (app, http_d) {
101
98
  request.get = function (... get) {
102
99
  return http_d.request.get (... get);
103
100
  }
101
+ if (request.visitor = {}) {
102
+ request.visitor.ip = {address: "127.0.0.1"}
103
+ request.visitor.browser = request.header ["user-agent"];
104
+ }
104
105
  return request;
105
106
  }
106
107
 
@@ -129,7 +130,16 @@ express.response = function (app, request, http_d) {
129
130
  * xxx://xxx.xxx.xxx/xxx
130
131
  */
131
132
 
132
- express.setup = function (request, response, next, http_d) {
133
+ express.security = function (request, response) {
134
+ this.emit ("security", request, response);
135
+ if (request.error.length) {
136
+ if (request.error.includes ("forbidden")) response.error.forbidden ();
137
+ else if (request.error.includes ("found")) response.error.found ();
138
+ else response.error ();
139
+ }
140
+ }
141
+
142
+ express.setup = function (request, response) {
133
143
  if (true) {
134
144
  response.output.set ("language", "en");
135
145
  response.output.set ("html:attribute", {translate: "no", prefix: "og: http://ogp.me/ns#"});
@@ -138,6 +148,9 @@ express.setup = function (request, response, next, http_d) {
138
148
  response.output.set ("debug", JSON.pretty (request.header));
139
149
  if (false) response.output.set ("meta", {attribute: {name: "adsterra", content: "ads"}});
140
150
  }
151
+ return new Promise (function (resolve, reject) {
152
+ resolve (true);
153
+ });
141
154
  }
142
155
 
143
156
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "express.io.js",
3
3
  "description": "Hello World",
4
- "version": "1.0.1248",
4
+ "version": "1.0.1611",
5
5
  "author": "Seindi Rahmat Barus <xseindi@gmail.com>",
6
6
  "contributors": [
7
7
  "Seindi Rahmat Barus <xseindi@gmail.com>"
@@ -22,6 +22,6 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "express": "^5.2.1",
25
- "script.io.js": "^1.0.1248"
25
+ "script.io.js": "^1.0.1611"
26
26
  }
27
27
  }