express.io.js 2026.122.1345 → 2026.124.153

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.
@@ -21,9 +21,10 @@ class express {
21
21
  this.host = this.config.host || "0.0.0.0";
22
22
  this.port = this.config.port || process.env.PORT || 3000;
23
23
  this.dir = {name: this.config.dir}
24
- this.dir.src = $.path.join (this.dir.name, "src")
25
- this.dir.db = $.path.join (this.dir.src, "db")
26
- this.dir.theme = $.path.join (this.dir.src, "theme")
24
+ this.dir.src = $.path.join (this.dir.name, "src");
25
+ this.dir.db = $.path.join (this.dir.src, "db");
26
+ this.dir.theme = $.path.join (this.dir.src, "theme");
27
+ this.db = this.config.db || {}
27
28
  Event.proto (this);
28
29
  }
29
30
  static (path = "public", option) {
@@ -36,8 +37,12 @@ class express {
36
37
  var http_d = {request: r, response: respond}
37
38
  var {request, response} = express.io (app, http_d);
38
39
  app.__ = {request, response}
40
+ if (request.url.path.startsWith ("/.well-known")) {
41
+ return response.status (403).send ("well-known")
42
+ }
39
43
  await new Promise (function (resolve, reject) { express.setup.call (app, app.__.request, app.__.response, resolve); });
40
- await new Promise (function (resolve, reject) { setup.call (app, app.__.request, app.__.response, resolve); });
44
+ console.log ("await", request.url.path, "done")
45
+ // await new Promise (function (resolve, reject) { setup.call (app, app.__.request, app.__.response, resolve); });
41
46
  express.security.call (app, app.__.request, app.__.response, next);
42
47
  }
43
48
  }
@@ -46,7 +51,7 @@ class express {
46
51
  }
47
52
  io (app, context) {
48
53
  return function (request, response, next) {
49
- context (app.__.request, app.__.response, next, {request, response});
54
+ return context (app.__.request, app.__.response, next, {request, response});
50
55
  }
51
56
  }
52
57
  use (... context) {
@@ -67,13 +72,13 @@ class express {
67
72
  for (var i in arguments) {
68
73
  if (typeof arguments [i] === "string") host = arguments [i];
69
74
  else if (typeof arguments [i] === "number") port = arguments [i];
70
- else if (typeof arguments [i] === "object") context = arguments [i];
75
+ else if (["object", "function"].includes (typeof arguments [i])) context = arguments [i];
71
76
  else {}
72
77
  }
73
78
  host = host || this.host;
74
79
  port = port || this.port;
75
80
  context = context || function () { console.log (`Express on Port`, port); }
76
- this.express.listen (port, host, context);
81
+ this.express.listen (port, host, context.call (this));
77
82
  return this;
78
83
  }
79
84
  export () {
@@ -90,8 +95,8 @@ express.io = function (app, http_d) {
90
95
  express.request = function (app, http_d) {
91
96
  const request = function () {}
92
97
  request.error = [];
93
- request.header = http_d.request.headers;
94
- if (request.url = function () {}) {
98
+ if (request.header = http_d.request.headers) {
99
+ request.url = function () {}
95
100
  var protocol = request.header ["x-forwarded-proto"] || http_d.request.protocol || "http";
96
101
  if (app.config.internet) protocol = "https";
97
102
  request.base_url = `${protocol}://${http_d.request.host}`;
@@ -111,37 +116,53 @@ express.request = function (app, http_d) {
111
116
  var country_timezone = request.header ["x-vercel-ip-timezone"] || "";
112
117
  var coordinate_latitude = request.header ["x-vercel-ip-latitude"] || "";
113
118
  var coordinate_longitude = request.header ["x-vercel-ip-longitude"] || "";
114
- request.visitor.ip = {address: ip_address}
115
- request.visitor.country = {code: country_code, name: country_name, region: country_region, city: {name: country_city_name}, timezone: country_timezone, coordinate: {latitude: coordinate_latitude, longitude: coordinate_longitude}}
116
- request.visitor.browser = request.header ["user-agent"];
119
+ request.visitor = {
120
+ ip: {address: ip_address},
121
+ country: {code: country_code, name: country_name, region: country_region, city: {name: country_city_name}, timezone: country_timezone, coordinate: {latitude: coordinate_latitude, longitude: coordinate_longitude}},
122
+ browser: request.header ["user-agent"],
123
+ }
124
+ }
125
+ if ("miscellaneous") {
126
+ request.date = new Date.io ();
127
+ request.db = function () {}
128
+ request.instance = function () {}
129
+ request.theme = function () {}
117
130
  }
118
- request.db = function () {}
119
- request.j_son = function () {}
120
- request.theme = function () {}
121
131
  return request;
122
132
  }
123
133
 
124
134
  express.response = function (app, request, http_d) {
125
135
  var response = function () {}
136
+ response.sent = http_d.response.headersSent;
137
+ http_d.response.on ("close", function () { app.emit ("close"); });
126
138
  if ("output") {
127
139
  response.var = $.object.create (null);
128
140
  response.output = new $.html ();
141
+ response.header = function () {}
142
+ response.header.set = function (key, value) { http_d.response.setHeader (key, value); return response; }
143
+ response.send = function (... data) {
144
+ console.log ("send", request.url.path)
145
+ if (response.end || response.sent) { console.log ("fuck you", request.url.path) }
146
+ else if (response.end = true) http_d.response.send (... data);
147
+ return response;
148
+ }
129
149
  response.status = function (code) { http_d.response.status (code); return response; }
130
- response.text = function () {}
131
- response.css = function () {}
132
- response.js = function () {}
133
- response.xml = function () {}
150
+ response.type = function (type) { http_d.response.type (type); return response; }
151
+ response.text = function (data) { response.type ("text").send (data); return response; }
152
+ response.css = function (data) { response.type ("css").send (data); return response; }
153
+ response.js = function (data) { response.type ("js").send (data); return response; }
154
+ response.xml = function (data) { response.type ("xml").send (data); return response; }
134
155
  response.json = function (... context) { http_d.response.json (... context); return response; }
135
156
  response.html = function (... context) {
136
- http_d.response.send (... context);
157
+ response.send (... context);
137
158
  return response;
138
159
  }
139
160
  response.render = function () {}
140
161
  }
141
162
  if ("error") {
142
- response.error = function (code = 500) { http_d.response.status (code).send (response.error.message || URL.header.status.code [code]); return response; }
143
- response.error.forbidden = function (code = 403) { http_d.response.status (code).send (URL.header.status.code [code]); return response; }
144
- response.error.found = function (code = 404) { http_d.response.status (code).send (URL.header.status.code [code]); return response; }
163
+ response.error = function () { var input = $.help.argument (... arguments), code, message; response.status (code = input.number || 500).send (message = input.string || response.error.message || URL.header.status.code [code]); return response; }
164
+ response.error.forbidden = function (message) { return response.error (403, message); }
165
+ response.error.found = function (message) { return response.error (404, message); }
145
166
  }
146
167
  if ("db") {
147
168
  response.db = function () {}
@@ -160,14 +181,11 @@ express.response = function (app, request, http_d) {
160
181
  */
161
182
 
162
183
  express.setup = async function (request, response, next) {
163
- if ("db") {
164
- if (this.config.db.driver === "json") request.db = new JSON.db ({dir: this.dir.db, collection: this.config.db.collection});
165
- if (this.config.db.driver === "appwrite") request.db = new $.appwrite.db ({id: this.config.db.id, host: this.config.db.host, project: this.config.db.project, collection: this.config.db.collection});
166
- }
167
- if ("app:client") {
168
- request.app = (await request.db.select ("app").find ({host: request.url.host.name})).data.one ()
169
- }
184
+ // await express.setup ["database"].call (this, request, response, next);
185
+ console.log ("setup", request.url.path, "done")
186
+ // await express.setup ["app"].call (this, request, response, next);
170
187
  if (true) {
188
+ // response.output.config ["manifest.json"] = request.app.meta.setting ["manifest.json"];
171
189
  response.output.set ("language", "en");
172
190
  response.output.set ("html:attribute", {translate: "no", prefix: "og: http://ogp.me/ns#"});
173
191
  response.output.set ("canonical", request.url.address);
@@ -176,16 +194,16 @@ express.setup = async function (request, response, next) {
176
194
  if (false) response.output.set ("meta", {attribute: {name: "key", content: "value"}});
177
195
  }
178
196
  this.emit ("setup", request, response);
179
- this.emit ("j_son:setup", request, response);
180
197
  next ();
181
198
  }
182
199
 
183
200
  express.security = function (request, response, next) {
184
201
  this.emit ("security", request, response);
185
202
  if (request.error.length) {
186
- if (request.error.includes ("forbidden")) response.error.forbidden ();
187
- else if (request.error.includes ("found")) response.error.found ();
188
- else response.error ();
203
+ console.log ("error", request.error)
204
+ if (request.error.includes ("forbidden")) return response.error.forbidden ();
205
+ else if (request.error.includes ("found")) return response.error.found ();
206
+ else return response.error ();
189
207
  }
190
208
  next ();
191
209
  }
@@ -200,6 +218,59 @@ express.security = function (request, response, next) {
200
218
  * xxx://xxx.xxx.xxx/xxx
201
219
  */
202
220
 
221
+ express.setup.database = async function (request, response, next) {
222
+ var app = this;
223
+ return new Promise (async function (resolve, reject) {
224
+ if (app.config.db.driver === "json") request.db = new JSON.db ({dir: app.dir.db, collection: app.config.db.collection});
225
+ if (app.config.db.driver === "appwrite") request.db = new $.appwrite.db ({id: app.config.db.id, host: app.config.db.host, project: app.config.db.project, collection: app.config.db.collection}, app.db.json);
226
+ request.instance.list = (await request.db.select ("instance").find ()).data;
227
+ console.log ("db", request.url.path, "done")
228
+ resolve ()
229
+ });
230
+ /*
231
+ return new Promise (function (resolve, reject) {
232
+ if (app.config.db.driver === "json") request.db = new JSON.db ({dir: app.dir.db, collection: app.config.db.collection});
233
+ if (app.config.db.driver === "appwrite") request.db = new $.appwrite.db ({id: app.config.db.id, host: app.config.db.host, project: app.config.db.project, collection: app.config.db.collection}, app.db.json);
234
+ request.instance.list = (await request.db.select ("instance").find ()).data
235
+ // request.instance.list = (await request.db.select ("instance").find ()).data
236
+ // request.theme.list = (await request.db.select ("theme").find ()).data
237
+ });
238
+ */
239
+ }
240
+
241
+ express.setup.app = async function (request, response, next) {
242
+ var app = {}
243
+ request.app = (await request.db.select ("app").limit (1).find ({host: request.url.host.name, status: "active"})).data.one ();
244
+ if (request.app) {
245
+ if (app = request.app.reference) {
246
+ app = request.app;
247
+ request.app = (await request.db.select ("app").limit (1).find (app.reference)).data.one ();
248
+ request.app.reference = app.serial;
249
+ request.app.type = app.type;
250
+ }
251
+ app.theme = request.app.theme.list.select ({status: "active"}).one ();
252
+ var theme = request.theme.list.select ({serial: app.theme.serial}).one ();
253
+ for (var i in theme) request.app.theme [i] = theme [i];
254
+ request.app.theme.version = app.theme.version;
255
+ request.app.theme.data = app.theme.data;
256
+ }
257
+ else {
258
+ request.error.push ("found");
259
+ next ();
260
+ }
261
+ return $.next ();
262
+ }
263
+
264
+ /**
265
+ * xxx
266
+ *
267
+ * title
268
+ * description
269
+ * sub description
270
+ *
271
+ * xxx://xxx.xxx.xxx/xxx
272
+ */
273
+
203
274
  module.exports = exports = express;
204
275
 
205
276
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "express.io.js",
3
3
  "description": "Hello World",
4
- "version": "2026.122.1345",
4
+ "version": "2026.124.153",
5
5
  "author": "Seindi Rahmat Barus <xseindi@gmail.com>",
6
6
  "contributors": [
7
7
  "Seindi Rahmat Barus <xseindi@gmail.com>"
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "express": "^5.2.1",
25
- "script.io.js": "^2026.122.1345",
25
+ "script.io.js": "^2026.124.153",
26
26
  "node-appwrite": "^21.1.0"
27
27
  }
28
28
  }