express.io.js 1.0.919 → 1.0.1248

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.
@@ -18,7 +18,7 @@ class express {
18
18
  this.express = $.express ();
19
19
  this.config = config;
20
20
  this.host = this.config.host || "0.0.0.0";
21
- this.port = process.env.PORT || this.config.port || 3000;
21
+ this.port = this.config.port || process.env.PORT || 3000;
22
22
  this.serve = this.config.static || {dotfiles: "ignore"}
23
23
  }
24
24
  static (path = "public", option) {
@@ -41,7 +41,12 @@ class express {
41
41
  }
42
42
  io (app, context) {
43
43
  return function (request, response, next) {
44
- context (app.__.request, app.__.response, next, {request, response});
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});
45
50
  }
46
51
  }
47
52
  use (... context) {
@@ -84,6 +89,7 @@ express.io = function (app, http_d) {
84
89
 
85
90
  express.request = function (app, http_d) {
86
91
  var request = function () {}
92
+ request.error = [];
87
93
  request.header = http_d.request.headers;
88
94
  if (request.url = function () {}) {
89
95
  var protocol = http_d.request.protocol || "http";
@@ -107,6 +113,9 @@ express.response = function (app, request, http_d) {
107
113
  return response;
108
114
  }
109
115
  response.output = new $.html ();
116
+ response.error = function (code = 500) { http_d.response.status (code).send (URL.header.status.code [code]); }
117
+ response.error.forbidden = function (code = 403) { http_d.response.status (code).send (URL.header.status.code [code]); }
118
+ response.error.found = function (code = 404) { http_d.response.status (code).send (URL.header.status.code [code]); }
110
119
  return response;
111
120
  }
112
121
 
@@ -121,12 +130,14 @@ express.response = function (app, request, http_d) {
121
130
  */
122
131
 
123
132
  express.setup = function (request, response, next, http_d) {
124
- response.output.set ("language", "en");
125
- response.output.set ("html:attribute", {translate: "no", prefix: "og: http://ogp.me/ns#"});
126
- response.output.set ("canonical", request.url.address);
127
- response.output.set ("favorite.ico", request.base_url.join ("/favicon.ico"));
128
- response.output.set ("debug", JSON.pretty (request.header));
129
- if (false) response.output.set ("meta", {attribute: {name: "adsterra", content: "ads"}});
133
+ if (true) {
134
+ response.output.set ("language", "en");
135
+ response.output.set ("html:attribute", {translate: "no", prefix: "og: http://ogp.me/ns#"});
136
+ response.output.set ("canonical", request.url.address);
137
+ response.output.set ("favorite.ico", request.base_url.join ("/favicon.ico"));
138
+ response.output.set ("debug", JSON.pretty (request.header));
139
+ if (false) response.output.set ("meta", {attribute: {name: "adsterra", content: "ads"}});
140
+ }
130
141
  }
131
142
 
132
143
  /**
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.919",
4
+ "version": "1.0.1248",
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.919"
25
+ "script.io.js": "^1.0.1248"
26
26
  }
27
27
  }