express.io.js 1.0.82 → 1.0.96
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/node_packages/express.js +50 -36
- package/package.json +2 -2
package/node_packages/express.js
CHANGED
|
@@ -15,70 +15,79 @@ $.express = require ("express");
|
|
|
15
15
|
|
|
16
16
|
class express {
|
|
17
17
|
constructor (config) {
|
|
18
|
-
this.
|
|
18
|
+
this.express = $.express ();
|
|
19
19
|
this.config = config;
|
|
20
|
+
this.host = this.config.host || "0.0.0.0";
|
|
21
|
+
this.port = process.env.PORT || this.config.port || 3000;
|
|
22
|
+
this.serve = this.config.static || {dotfiles: "ignore"}
|
|
20
23
|
}
|
|
21
|
-
static (path = "public", option
|
|
22
|
-
|
|
24
|
+
static (path = "public", option) {
|
|
25
|
+
var serve = option || this.serve;
|
|
26
|
+
this.express.use ($.express.static (path, serve));
|
|
23
27
|
return this;
|
|
24
28
|
}
|
|
25
29
|
setup (context) {
|
|
26
|
-
var io = function (
|
|
30
|
+
var io = function (app) {
|
|
27
31
|
return function (r, respond, next) {
|
|
28
32
|
var http_d = {request: r, response: respond}
|
|
29
|
-
var {request, response} = express.io (
|
|
30
|
-
|
|
31
|
-
express.setup (
|
|
32
|
-
context (
|
|
33
|
+
var {request, response} = express.io (app, http_d);
|
|
34
|
+
app.__ = {request, response}
|
|
35
|
+
express.setup (app.__.request, app.__.response, next, http_d);
|
|
36
|
+
context (app.__.request, app.__.response, next, http_d);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
|
-
this.
|
|
39
|
+
this.express.use (io (this));
|
|
36
40
|
return this;
|
|
37
41
|
}
|
|
38
|
-
io (
|
|
42
|
+
io (app, context) {
|
|
39
43
|
return function (request, response, next) {
|
|
40
|
-
context (
|
|
44
|
+
context (app.__.request, app.__.response, next, {request, response});
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
use (... context) {
|
|
44
|
-
this.
|
|
48
|
+
this.express.use (... context);
|
|
45
49
|
return this;
|
|
46
50
|
}
|
|
47
51
|
get (path, context) {
|
|
48
|
-
this.
|
|
52
|
+
this.express.get (path, this.io (this, context));
|
|
49
53
|
return this;
|
|
50
54
|
}
|
|
51
55
|
catch (context) {
|
|
52
|
-
this.
|
|
56
|
+
this.express.use (this.io (this, context));
|
|
53
57
|
return this;
|
|
54
58
|
}
|
|
55
|
-
listen (
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
listen () {
|
|
60
|
+
var host, port;
|
|
61
|
+
var context;
|
|
62
|
+
for (var i in arguments) {
|
|
63
|
+
if (typeof arguments [i] === "string") host = arguments [i];
|
|
64
|
+
else if (typeof arguments [i] === "number") port = arguments [i];
|
|
65
|
+
else if (typeof arguments [i] === "object") context = arguments [i];
|
|
66
|
+
else {}
|
|
67
|
+
}
|
|
68
|
+
host = host || this.host;
|
|
69
|
+
port = port || this.port;
|
|
70
|
+
context = context || function () { console.log (`Express on Port`, port); }
|
|
71
|
+
this.express.listen (port, host, context);
|
|
58
72
|
return this;
|
|
59
73
|
}
|
|
74
|
+
export () {
|
|
75
|
+
return this.express;
|
|
76
|
+
}
|
|
60
77
|
}
|
|
61
78
|
|
|
62
|
-
express.
|
|
63
|
-
|
|
64
|
-
response.
|
|
65
|
-
response.output.set ("canonical", request.url.address);
|
|
66
|
-
response.output.set ("favorite.ico", request.base_url.join ("/favicon.ico"));
|
|
67
|
-
response.output.set ("meta", {attribute: {name: "adsterra", content: "ads"}});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
express.io = function (application, app, http_d) {
|
|
71
|
-
var request = express.request (application, app, http_d);
|
|
72
|
-
var response = express.response (application, app, request, http_d);
|
|
79
|
+
express.io = function (app, http_d) {
|
|
80
|
+
var request = express.request (app, http_d);
|
|
81
|
+
var response = express.response (app, request, http_d);
|
|
73
82
|
return {request, response}
|
|
74
83
|
}
|
|
75
84
|
|
|
76
|
-
express.request = function (
|
|
85
|
+
express.request = function (app, http_d) {
|
|
77
86
|
var request = function () {}
|
|
78
87
|
request.header = http_d.request.headers;
|
|
79
88
|
if (request.url = function () {}) {
|
|
80
89
|
var protocol = http_d.request.protocol || "http";
|
|
81
|
-
if (
|
|
90
|
+
if (app.config.internet) protocol = "https";
|
|
82
91
|
request.base_url = `${protocol}://${http_d.request.host}`;
|
|
83
92
|
var parse_url = URL.parse (request.url.address = `${request.base_url}${http_d.request.url}`);
|
|
84
93
|
for (var i in parse_url) request.url [i] = parse_url [i];
|
|
@@ -89,7 +98,7 @@ express.request = function (application, app, http_d) {
|
|
|
89
98
|
return request;
|
|
90
99
|
}
|
|
91
100
|
|
|
92
|
-
express.response = function (
|
|
101
|
+
express.response = function (app, request, http_d) {
|
|
93
102
|
var response = function () {}
|
|
94
103
|
response.status = function (code) { http_d.response.status (code); return response; }
|
|
95
104
|
response.json = function (... context) { http_d.response.json (... context); return response; }
|
|
@@ -111,6 +120,15 @@ express.response = function (application, app, request, http_d) {
|
|
|
111
120
|
* xxx://xxx.xxx.xxx/xxx
|
|
112
121
|
*/
|
|
113
122
|
|
|
123
|
+
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"}});
|
|
130
|
+
}
|
|
131
|
+
|
|
114
132
|
/**
|
|
115
133
|
* xxx
|
|
116
134
|
*
|
|
@@ -124,11 +142,7 @@ express.response = function (application, app, request, http_d) {
|
|
|
124
142
|
module.exports = exports = express;
|
|
125
143
|
|
|
126
144
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* title
|
|
130
|
-
* description
|
|
131
|
-
* sub description
|
|
145
|
+
* the end
|
|
132
146
|
*
|
|
133
147
|
* xxx://xxx.xxx.xxx/xxx
|
|
134
148
|
*/
|
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.
|
|
4
|
+
"version": "1.0.96",
|
|
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.
|
|
25
|
+
"script.io.js": "^1.0.96"
|
|
26
26
|
}
|
|
27
27
|
}
|