isite 2025.1.6 → 2025.1.11

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/lib/routing.js CHANGED
@@ -1,1534 +1,1538 @@
1
1
  module.exports = function init(____0) {
2
- ____0.on(____0.strings[4], (_) => {
3
- if (!_) {
4
- _0xrrxo.list = _0xrrxo.list.filter((r) => r.name.like('*x-api*'));
5
- }
6
- });
7
-
8
- let _0xrrxo = function () {};
9
-
10
- _0xrrxo.list = [];
11
-
12
- _0xrrxo.endResponse = function (req, res) {
13
- let route = req.route;
14
-
15
- if (route.empty) {
16
- if (____0.options.help) {
17
- res.set('help-error-message', 'route is empty');
18
- }
19
- res.end();
20
- return;
21
- }
22
-
23
- if (req.route.encript == '123') {
24
- req.content = ____0.f1(req.content);
25
- }
26
-
27
- if (route.parser.like('*html*') && route.content && route.content.length > 0) {
28
- req.content = ____0.parser(req, res, ____0, route).html(route.content);
29
- } else if (route.parser == 'css' && route.content && route.content.length > 0) {
30
- req.content = ____0.parser(req, res, ____0, route).css(route.content);
31
- } else if (route.parser == 'js' && route.content && route.content.length > 0) {
32
- req.content = ____0.parser(req, res, ____0, route).js(route.content);
33
- } else {
34
- req.content = route.content;
35
- }
36
-
37
- if (route.compress) {
38
- req.content = req.content.replace(/\r?\n|\r/g, ' ').replace(/\s+/g, ' ');
39
- }
40
-
41
- route.path = route.path || '';
42
-
43
- // let hash = req.content ? ____0.x0md50x(req.content) : ____0.x0md50x('');
44
- let last_modified = new Date().toUTCString();
45
- if (route.stat) {
46
- last_modified = new Date(route.stat.mtimeMs).toUTCString();
47
- }
48
-
49
- // if (req.headers['if-none-match'] == hash) {
50
- // if (____0.options.help) {
51
- // res.set('help-info-message', 'etag matched');
52
- // }
53
- // // res.status(304).end(null);
54
- // // return;
55
- // }
56
-
57
- // res.set('ETag', hash);
58
-
59
- if (____0.options.cache.enabled) {
60
- res.set('Last-Modified', last_modified);
61
- }
62
-
63
- if (route.headers) {
64
- for (const property in route.headers) {
65
- res.set(property, route.headers[property]);
66
- }
67
- }
68
-
69
- if (true) {
70
- if (route.path.endsWith('.css')) {
71
- res.set(____0.strings[7], 'text/css');
72
- if (____0.options.cache.enabled) {
73
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.css);
74
- }
75
- } else if (route.path.endsWith('.js')) {
76
- res.set(____0.strings[7], 'application/javascript');
77
- if (____0.options.cache.enabled) {
78
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.js);
79
- }
80
- } else if (route.path.endsWith('.html')) {
81
- res.set(____0.strings[7], 'text/html');
82
- if (____0.options.cache.enabled && route.cache) {
83
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.html);
84
- }
85
- } else if (route.path.endsWith('.txt')) {
86
- res.set(____0.strings[7], 'text/plain');
87
- if (____0.options.cache.enabled) {
88
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.txt);
2
+ ____0.on(____0.strings[4], (_) => {
3
+ if (!_) {
4
+ _0xrrxo.list = _0xrrxo.list.filter((r) => r.name.like('*x-api*'));
89
5
  }
90
- } else if (route.path.endsWith('.json')) {
91
- res.set(____0.strings[7], 'application/json');
92
- if (____0.options.cache.enabled) {
93
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.json);
94
- }
95
- } else if (route.path.endsWith('.xml')) {
96
- res.set(____0.strings[7], 'text/xml');
97
- if (____0.options.cache.enabled) {
98
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.xml);
99
- }
100
- } else if (route.path.endsWith('.woff2')) {
101
- res.set(____0.strings[7], 'application/font-woff2');
102
- if (____0.options.cache.enabled) {
103
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
104
- }
105
- } else if (route.path.endsWith('.woff')) {
106
- res.set(____0.strings[7], 'application/font-woff');
107
- if (____0.options.cache.enabled) {
108
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
109
- }
110
- } else if (route.path.endsWith('.ttf')) {
111
- res.set(____0.strings[7], 'application/font-ttf');
112
- if (____0.options.cache.enabled) {
113
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
114
- }
115
- } else if (route.path.endsWith('.otf')) {
116
- res.set(____0.strings[7], 'application/font-otf');
117
- if (____0.options.cache.enabled) {
118
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
119
- }
120
- } else if (route.path.endsWith('.eot')) {
121
- res.set(____0.strings[7], 'application/font-eot');
122
- if (____0.options.cache.enabled) {
123
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
124
- }
125
- } else if (route.path.endsWith('.gif')) {
126
- res.set(____0.strings[7], 'image/gif');
127
- if (____0.options.cache.enabled) {
128
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
129
- }
130
- } else if (route.path.endsWith('.png')) {
131
- res.set(____0.strings[7], 'image/png');
132
- if (____0.options.cache.enabled) {
133
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
6
+ });
7
+
8
+ let _0xrrxo = function () {};
9
+
10
+ _0xrrxo.list = [];
11
+
12
+ _0xrrxo.endResponse = function (req, res) {
13
+ let route = req.route;
14
+
15
+ if (route.empty) {
16
+ if (____0.options.help) {
17
+ res.set('help-error-message', 'route is empty');
18
+ }
19
+ res.end();
20
+ return;
134
21
  }
135
- } else if (route.path.endsWith('.jpg')) {
136
- res.set(____0.strings[7], 'image/jpg');
137
- if (____0.options.cache.enabled) {
138
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
22
+
23
+ if (req.route.encript == '123') {
24
+ req.content = ____0.f1(req.content);
139
25
  }
140
- } else if (route.path.endsWith('.jpeg')) {
141
- res.set(____0.strings[7], 'image/jpeg');
142
- if (____0.options.cache.enabled) {
143
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
26
+
27
+ if (route.parser.like('*html*') && route.content && route.content.length > 0) {
28
+ req.content = ____0.parser(req, res, ____0, route).html(route.content);
29
+ } else if (route.parser == 'css' && route.content && route.content.length > 0) {
30
+ req.content = ____0.parser(req, res, ____0, route).css(route.content);
31
+ } else if (route.parser == 'js' && route.content && route.content.length > 0) {
32
+ req.content = ____0.parser(req, res, ____0, route).js(route.content);
33
+ } else {
34
+ req.content = route.content;
144
35
  }
145
- } else if (route.path.endsWith('.ico')) {
146
- res.set(____0.strings[7], 'image/ico');
147
- if (____0.options.cache.enabled) {
148
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
36
+
37
+ if (route.compress) {
38
+ req.content = req.content.replace(/\r?\n|\r/g, ' ').replace(/\s+/g, ' ');
149
39
  }
150
- } else if (route.path.endsWith('.bmp')) {
151
- res.set(____0.strings[7], 'image/bmp');
152
- if (____0.options.cache.enabled) {
153
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
40
+
41
+ route.path = route.path || '';
42
+
43
+ // let hash = req.content ? ____0.x0md50x(req.content) : ____0.x0md50x('');
44
+ let last_modified = new Date().toUTCString();
45
+ if (route.stat) {
46
+ last_modified = new Date(route.stat.mtimeMs).toUTCString();
154
47
  }
155
- } else if (route.path.endsWith('.webp')) {
156
- res.set(____0.strings[7], 'image/webp');
48
+
49
+ // if (req.headers['if-none-match'] == hash) {
50
+ // if (____0.options.help) {
51
+ // res.set('help-info-message', 'etag matched');
52
+ // }
53
+ // // res.status(304).end(null);
54
+ // // return;
55
+ // }
56
+
57
+ // res.set('ETag', hash);
58
+
157
59
  if (____0.options.cache.enabled) {
158
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
60
+ res.set('Last-Modified', last_modified);
159
61
  }
160
- } else if (route.path.endsWith('.svg')) {
161
- res.set(____0.strings[7], 'image/svg+xml');
162
- if (____0.options.cache.enabled) {
163
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
62
+
63
+ if (route.headers) {
64
+ for (const property in route.headers) {
65
+ res.set(property, route.headers[property]);
66
+ }
164
67
  }
165
- }
166
- }
167
-
168
- let response = {
169
- host: req.host,
170
- url: req.url,
171
- filePath: route.path,
172
- content: req.content,
173
- encode: ____0.getFileEncode(route.path),
174
- headers: res.headers,
175
- code: res.code,
176
- };
177
68
 
178
- if (route.shared && !____0.sharedList.some((s) => s.host == req.host && s.filePath == response.filePath && s.url == response.url)) {
179
- ____0.sharedList.push(response);
180
- }
181
-
182
- if (typeof response.content == 'object') {
183
- res.json(response.content);
184
- } else {
185
- res.end(response.content, response.encode);
186
- }
187
- };
188
-
189
- _0xrrxo.defaultCallback = function (req, res) {
190
- let route = req.route;
191
-
192
- if ((response = ____0.sharedList.find((s) => s.host == req.host && s.filePath == route.path && s.url == req.url))) {
193
- res.headers = response.headers;
194
- res.code = response.code;
195
- res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length + ' -count=' + req.route.count);
196
- return res.end(response.content, response.encode);
197
- }
198
-
199
- if (route.cache && route.content) {
200
- if (____0.options.help) {
201
- res.set('help-info-content', 'From Route Memory');
202
- }
203
-
204
- res.status(200);
205
- _0xrrxo.endResponse(req, res);
206
- return;
207
- }
208
-
209
- if (route.empty) {
210
- res.status(404);
211
- _0xrrxo.endResponse(req, res);
212
- return;
213
- }
214
-
215
- if (!route.path && !route.content) {
216
- if (____0.options.help) {
217
- res.set('help-info-content', 'Route Not Set File Path');
218
- }
219
- res.status(200);
220
- _0xrrxo.endResponse(req, res);
221
- return;
222
- } else if (route.content) {
223
- if (____0.options.help) {
224
- res.set('help-info-content', 'Content From Route init');
225
- }
226
- res.status(200);
227
- _0xrrxo.endResponse(req, res);
228
- }
229
-
230
- if (typeof route.path == 'string') {
231
- ____0.readFile(route.path, function (err, file) {
232
- if (!err) {
233
- route.content = file.content.toString('utf8');
234
- if (route.encript && route.encript === '123') {
235
- route.content = ____0.f1(route.content);
236
- }
237
- route.stat = file.stat;
238
- if (route.masterPage) {
239
- for (var i = 0; i < ____0.masterPages.length; i++) {
240
- if (route.masterPage == ____0.masterPages[i].name) {
241
- route.content = ____0.readFileSync(____0.masterPages[i].header) + route.content + ____0.readFileSync(____0.masterPages[i].footer);
242
- break;
243
- }
69
+ if (true) {
70
+ if (route.path.endsWith('.css')) {
71
+ res.set(____0.strings[7], 'text/css');
72
+ if (____0.options.cache.enabled) {
73
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.css);
74
+ }
75
+ } else if (route.path.endsWith('.js')) {
76
+ res.set(____0.strings[7], 'application/javascript');
77
+ if (____0.options.cache.enabled) {
78
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.js);
79
+ }
80
+ } else if (route.path.endsWith('.html')) {
81
+ res.set(____0.strings[7], 'text/html');
82
+ if (____0.options.cache.enabled && route.cache) {
83
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.html);
84
+ }
85
+ } else if (route.path.endsWith('.txt')) {
86
+ res.set(____0.strings[7], 'text/plain');
87
+ if (____0.options.cache.enabled) {
88
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.txt);
89
+ }
90
+ } else if (route.path.endsWith('.json')) {
91
+ res.set(____0.strings[7], 'application/json');
92
+ if (____0.options.cache.enabled) {
93
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.json);
94
+ }
95
+ } else if (route.path.endsWith('.xml')) {
96
+ res.set(____0.strings[7], 'text/xml');
97
+ if (____0.options.cache.enabled) {
98
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.xml);
99
+ }
100
+ } else if (route.path.endsWith('.woff2')) {
101
+ res.set(____0.strings[7], 'application/font-woff2');
102
+ if (____0.options.cache.enabled) {
103
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
104
+ }
105
+ } else if (route.path.endsWith('.woff')) {
106
+ res.set(____0.strings[7], 'application/font-woff');
107
+ if (____0.options.cache.enabled) {
108
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
109
+ }
110
+ } else if (route.path.endsWith('.ttf')) {
111
+ res.set(____0.strings[7], 'application/font-ttf');
112
+ if (____0.options.cache.enabled) {
113
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
114
+ }
115
+ } else if (route.path.endsWith('.otf')) {
116
+ res.set(____0.strings[7], 'application/font-otf');
117
+ if (____0.options.cache.enabled) {
118
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
119
+ }
120
+ } else if (route.path.endsWith('.eot')) {
121
+ res.set(____0.strings[7], 'application/font-eot');
122
+ if (____0.options.cache.enabled) {
123
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
124
+ }
125
+ } else if (route.path.endsWith('.gif')) {
126
+ res.set(____0.strings[7], 'image/gif');
127
+ if (____0.options.cache.enabled) {
128
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
129
+ }
130
+ } else if (route.path.endsWith('.png')) {
131
+ res.set(____0.strings[7], 'image/png');
132
+ if (____0.options.cache.enabled) {
133
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
134
+ }
135
+ } else if (route.path.endsWith('.jpg')) {
136
+ res.set(____0.strings[7], 'image/jpg');
137
+ if (____0.options.cache.enabled) {
138
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
139
+ }
140
+ } else if (route.path.endsWith('.jpeg')) {
141
+ res.set(____0.strings[7], 'image/jpeg');
142
+ if (____0.options.cache.enabled) {
143
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
144
+ }
145
+ } else if (route.path.endsWith('.ico')) {
146
+ res.set(____0.strings[7], 'image/ico');
147
+ if (____0.options.cache.enabled) {
148
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
149
+ }
150
+ } else if (route.path.endsWith('.bmp')) {
151
+ res.set(____0.strings[7], 'image/bmp');
152
+ if (____0.options.cache.enabled) {
153
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
154
+ }
155
+ } else if (route.path.endsWith('.webp')) {
156
+ res.set(____0.strings[7], 'image/webp');
157
+ if (____0.options.cache.enabled) {
158
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
159
+ }
160
+ } else if (route.path.endsWith('.svg')) {
161
+ res.set(____0.strings[7], 'image/svg+xml');
162
+ if (____0.options.cache.enabled) {
163
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
164
+ }
244
165
  }
245
- }
166
+ }
246
167
 
247
- if (____0.options.help) {
248
- res.set('help-info-content', 'Route Read File');
249
- }
168
+ let response = {
169
+ host: req.host,
170
+ url: req.url,
171
+ filePath: route.path,
172
+ content: req.content,
173
+ encode: ____0.getFileEncode(route.path),
174
+ headers: res.headers,
175
+ code: res.code,
176
+ };
250
177
 
251
- res.status(200);
252
- _0xrrxo.endResponse(req, res);
253
- } else {
254
- if (____0.options.help) {
255
- res.set('help-error', 'Route Error Read File');
256
- }
257
-
258
- res.status(404);
259
- route.empty = !0;
260
- _0xrrxo.endResponse(req, res);
261
- return;
178
+ if (route.shared && !____0.sharedList.some((s) => s.host == req.host && s.filePath == response.filePath && s.url == response.url)) {
179
+ ____0.sharedList.push(response);
262
180
  }
263
- });
264
- } else if (typeof route.path == 'object') {
265
- ____0.readFiles(route.path, function (err, data) {
266
- if (!err) {
267
- if (____0.options.help) {
268
- res.set('help-info-content', 'Route Read Files');
269
- }
270
-
271
- route.content = data.toString('utf8');
272
-
273
- res.status(200);
274
- route.path = route.path.join('&&');
275
- _0xrrxo.endResponse(req, res);
181
+
182
+ if (typeof response.content == 'object') {
183
+ res.json(response.content);
276
184
  } else {
277
- if (____0.options.help) {
278
- res.set('help-error', 'Route Error Read Files');
279
- }
280
-
281
- res.status(404);
282
- route.empty = !0;
283
- _0xrrxo.endResponse(req, res);
284
- return;
185
+ res.end(response.content, response.encode);
285
186
  }
286
- });
287
- }
288
- };
289
-
290
- _0xrrxo.call = function (r, req, res, callback) {
291
- callback =
292
- callback ||
293
- function (req, res) {
294
- ____0.log('No CallBack set For : ', r);
295
- res.end();
296
- };
297
- if (typeof r === 'string') {
298
- r = {
299
- name: r,
300
- method: req.method,
301
- };
302
- }
303
-
304
- let exists = false;
305
- _0xrrxo.list.forEach((rr) => {
306
- if (exists) {
307
- return;
308
- }
309
- if ((rr.name == r.name || rr.nameRaw == r.name) && rr.method == r.method) {
310
- exists = true;
311
- req.route = rr;
312
- rr.callback(req, res);
313
- }
314
- });
187
+ };
315
188
 
316
- if (!exists) {
317
- callback(req, res);
318
- }
319
- };
320
- _0xrrxo.off = function (r) {
321
- if (!r) {
322
- return;
323
- }
324
- if (typeof r == 'string') {
325
- r = { name: r };
326
- }
327
- if (!r.name.startsWith('/')) {
328
- r.name = '/' + r.name;
329
- }
330
-
331
- for (let i = _0xrrxo.list.length; i--; ) {
332
- let oldRoute = _0xrrxo.list[i];
333
- if (r.name && r.method && oldRoute.name.like(r.name) && oldRoute.method.like(r.method)) {
334
- _0xrrxo.list.splice(i, 1);
335
- ____0.fsm.off(oldRoute.path);
336
- } else if (r.name && r.method && oldRoute.nameRaw.like(r.name) && oldRoute.method.like(r.method)) {
337
- _0xrrxo.list.splice(i, 1);
338
- ____0.fsm.off(oldRoute.path);
339
- } else if (r.name && oldRoute.name.like(r.name)) {
340
- _0xrrxo.list.splice(i, 1);
341
- ____0.fsm.off('*' + oldRoute.name.replace('/', '') + '*');
342
- ____0.fsm.off(oldRoute.path);
343
- } else if (r.name && oldRoute.nameRaw.like(r.name)) {
344
- _0xrrxo.list.splice(i, 1);
345
- ____0.fsm.off('*' + oldRoute.name.replace('/', '') + '*');
346
- ____0.fsm.off(oldRoute.path);
347
- } else if (r.method && oldRoute.method.like(r.method)) {
348
- _0xrrxo.list.splice(i, 1);
349
- ____0.fsm.off(oldRoute.path);
350
- }
351
- }
352
- };
353
- _0xrrxo.add = function (r, callback) {
354
- if (Array.isArray(r)) {
355
- r.forEach((r2) => {
356
- _0xrrxo.add(r2, callback);
357
- });
358
- return;
359
- }
360
- if (r && r.name && Array.isArray(r.name)) {
361
- r.name.forEach((r2) => {
362
- let r3 = { ...r };
363
- r3.name = r2;
364
- _0xrrxo.onREQUEST(r3, r.callback);
365
- });
366
- return;
367
- }
368
- let route = {};
369
-
370
- if (typeof r == 'string') {
371
- route.name = r.toLowerCase();
372
- route.nameRaw = r;
373
- route.public = ____0.options.public || false;
374
- route.method = 'GET';
375
- route.path = null;
376
- route.parser = 'static';
377
- route.parserDir = ____0.dir;
378
- route.count = 0;
379
- route.cache = !0;
380
- route.hide = !1;
381
- route.compress = !1;
382
- route.encript = !1;
383
- route.shared = !1;
384
- route.content = null;
385
- route.headers = null;
386
- route.map = [];
387
- route.callback = callback ?? _0xrrxo.defaultCallback;
388
- if (route.public) {
389
- route.require = {
390
- features: [],
391
- permissions: [],
392
- };
393
- } else {
394
- route.require = ____0.options.require;
395
- route.default = ____0.options.defaults;
396
- }
397
- } else {
398
- route.name = r.name.toLowerCase();
399
- route.nameRaw = r.name;
400
- route.public = r.public ?? (____0.options.public || false);
401
- route.method = r.method || 'GET';
402
- route.path = r.path || null;
403
- route.lang = r.lang || null;
404
- route.content = r.content;
405
- route.headers = r.headers;
406
- route.parser = r.parser || 'static';
407
- route.parserDir = r.parserDir || ____0.dir;
408
- route.masterPage = r.masterPage || null;
409
- route.overwrite = r.overwrite ?? !1;
410
- route.cache = r.cache ?? !0;
411
- route.count = r.count || 0;
412
- route.hide = r.hide ?? !1;
413
- route.compress = r.compress ?? !1;
414
- route.encript = r.encript ?? !1;
415
- route.shared = r.shared ?? !1;
416
- route.map = r.map || [];
417
- route.callback = callback || r.callback || _0xrrxo.defaultCallback;
418
-
419
- if (route.public) {
420
- route.require = {
421
- features: [],
422
- permissions: [],
423
- };
424
- } else {
425
- route.require = r.require ?? ____0.options.require;
426
- route.require.features = route.require.features ?? ____0.options.require.features;
427
- route.require.permissions = route.require.permissions ?? ____0.options.require.permissions;
428
-
429
- route.default = r.default ?? ____0.options.defaults;
430
- route.default.features = route.default.features ?? ____0.options.defaults.features;
431
- route.default.permissions = route.default.permissions ?? ____0.options.defaults.permissions;
432
- }
433
- }
434
-
435
- if (!route.name.startsWith('/')) {
436
- route.name = '/' + route.name;
437
- route.nameRaw = '/' + route.nameRaw;
438
- }
439
-
440
- route.name = route.name.replace('//', '/');
441
- route.nameRaw = route.nameRaw.replace('//', '/');
442
-
443
- let arr = route.name.split('/');
444
- let arr0 = route.nameRaw.split('/');
445
-
446
- for (var i = 0; i < arr.length; i++) {
447
- var s = arr[i];
448
- var s0 = arr0[i];
449
-
450
- if (s.startsWith(':')) {
451
- arr[i] = '*';
452
- let name = s.replace(':', '');
453
- let nameRaw = s0.replace(':', '');
454
-
455
- route.map.push({
456
- index: i,
457
- name: name,
458
- isLower: !1,
459
- });
460
- if (name !== nameRaw) {
461
- route.map.push({
462
- index: i,
463
- name: nameRaw,
464
- isLower: !0,
465
- });
189
+ _0xrrxo.defaultCallback = function (req, res) {
190
+ let route = req.route;
191
+
192
+ if ((response = ____0.sharedList.find((s) => s.host == req.host && s.filePath == route.path && s.url == req.url))) {
193
+ res.headers = response.headers;
194
+ res.code = response.code;
195
+ res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length + ' -count=' + req.route.count);
196
+ return res.end(response.content, response.encode);
466
197
  }
467
- }
468
- }
469
- try {
470
- route.name = arr.join('/');
471
- if (typeof route.path == 'string' && ____0.fs.lstatSync(route.path).isDirectory()) {
472
- ____0.fs.readdir(route.path, (err, files) => {
473
- files.forEach((file) => {
474
- let r2 = { ...route };
475
- if (route.name.endsWith('/')) {
476
- r2.name = route.name + file;
477
- } else {
478
- r2.name = route.name + '/' + file;
198
+
199
+ if (route.cache && route.content) {
200
+ if (____0.options.help) {
201
+ res.set('help-info-content', 'From Route Memory');
479
202
  }
480
203
 
481
- r2.path = route.path + '/' + file;
482
- r2.is_dynamic = !0;
483
- _0xrrxo.add(r2);
484
- });
485
- });
486
- } else {
487
- if (!route.name.startsWith('/')) {
488
- route.name = '/' + route.name;
204
+ res.status(200);
205
+ _0xrrxo.endResponse(req, res);
206
+ return;
489
207
  }
490
208
 
491
- route.name = encodeURI(route.name);
492
- let index = _0xrrxo.list.findIndex((rr) => rr.name == route.name && rr.method == route.method);
493
- if (index === -1) {
494
- _0xrrxo.list.push(route);
495
- } else if (!route.overwrite) {
496
- if (route.name.like('*api/*')) {
497
- ____0.log('[ Duplicate API ] ' + route.name);
498
- } else {
499
- ____0.log('[ Duplicate Route ] ' + route.name);
500
- }
501
- } else {
502
- _0xrrxo.list[index] = route;
209
+ if (route.empty) {
210
+ res.status(404);
211
+ _0xrrxo.endResponse(req, res);
212
+ return;
503
213
  }
504
- }
505
- } catch (err) {
506
- ____0.log(err);
507
- return null;
508
- }
509
- };
510
-
511
- _0xrrxo.onREQUEST = function (type, r, callback) {
512
- if (Array.isArray(r)) {
513
- r.forEach((r2) => {
514
- _0xrrxo.onREQUEST(type, r2, callback);
515
- });
516
- return;
517
- }
518
- let route = {};
519
- if (typeof r == 'string') {
520
- route = {
521
- name: r,
522
- method: type,
523
- callback: callback || _0xrrxo.defaultCallback,
524
- };
525
- } else {
526
- route = r;
527
-
528
- if (Array.isArray(r.name)) {
529
- r.name.forEach((n) => {
530
- let sub_route = { ...route };
531
- sub_route.name = n;
532
- _0xrrxo.onREQUEST(type, sub_route, callback);
533
- });
534
- return;
535
- }
536
- route.callback = route.callback || callback || _0xrrxo.defaultCallback;
537
- }
538
- route.method = type;
539
- _0xrrxo.add(route);
540
- };
541
-
542
- _0xrrxo.onGET = function (r, callback) {
543
- _0xrrxo.onREQUEST('GET', r, callback);
544
- };
545
- _0xrrxo.onPOST = function (r, callback) {
546
- _0xrrxo.onREQUEST('POST', r, callback);
547
- };
548
- _0xrrxo.onPUT = function (r, callback) {
549
- _0xrrxo.onREQUEST('PUT', r, callback);
550
- };
551
- _0xrrxo.onDELETE = function (r, callback) {
552
- _0xrrxo.onREQUEST('DELETE', r, callback);
553
- };
554
-
555
- _0xrrxo.onTEST = function (r, callback) {
556
- _0xrrxo.onREQUEST('TEST', r, callback);
557
- };
558
-
559
- _0xrrxo.onVIEW = function (r, callback) {
560
- _0xrrxo.onREQUEST('VIEW', r, callback);
561
- };
562
- _0xrrxo.onOPTIONS = function (r, callback) {
563
- _0xrrxo.onREQUEST('OPTIONS', r, callback);
564
- };
565
- _0xrrxo.onPATCH = function (r, callback) {
566
- _0xrrxo.onREQUEST('PATCH', r, callback);
567
- };
568
- _0xrrxo.onCOPY = function (r, callback) {
569
- _0xrrxo.onREQUEST('COPY', r, callback);
570
- };
571
- _0xrrxo.onHEAD = function (r, callback) {
572
- _0xrrxo.onREQUEST('HEAD', r, callback);
573
- };
574
- _0xrrxo.onLINK = function (r, callback) {
575
- _0xrrxo.onREQUEST('LINK', r, callback);
576
- };
577
- _0xrrxo.onUNLINK = function (r, callback) {
578
- _0xrrxo.onREQUEST('UNLINK', r, callback);
579
- };
580
- _0xrrxo.onPURGE = function (r, callback) {
581
- _0xrrxo.onREQUEST('PURGE', r, callback);
582
- };
583
- _0xrrxo.onLOCK = function (r, callback) {
584
- _0xrrxo.onREQUEST('LOCK', r, callback);
585
- };
586
- _0xrrxo.onUNLOCK = function (r, callback) {
587
- _0xrrxo.onREQUEST('UNLOCK', r, callback);
588
- };
589
- _0xrrxo.onPROPFIND = function (r, callback) {
590
- _0xrrxo.onREQUEST('PROPFIND', r, callback);
591
- };
592
-
593
- _0xrrxo.onALL = _0xrrxo.onANY = function (r, callback) {
594
- _0xrrxo.onREQUEST('*', r, callback);
595
- };
596
-
597
- _0xrrxo.handleRoute = async function (req, res, route) {
598
- if (route.language) {
599
- req.session.language = { ...route.language };
600
- }
601
-
602
- if (route.lang) {
603
- req.session.language.id = route.lang;
604
- }
605
-
606
- if (!route.public) {
607
- if (!route.name.like(____0.strings[15]) && route.require.features.length > 0) {
608
- let ok = !0;
609
- route.require.features.forEach((feature) => {
610
- if (!req.hasFeature(feature)) {
611
- ok = !1;
612
- }
613
- });
614
- if (!ok) {
615
- res.status(401);
616
- if (route.name.contains(____0.strings[16])) {
617
- return res.json({
618
- done: !1,
619
- error: ____0.strings[13],
620
- features: route.require.features,
621
- });
622
- } else
623
- return res.render(
624
- ____0.strings[11],
625
- {
626
- features: route.require.features,
627
- html: ` ${____0.strings[13]} : ${route.require.features.join(',')}`,
628
- },
629
- {
630
- parser: ____0.strings[17],
631
- }
632
- );
214
+
215
+ if (!route.path && !route.content) {
216
+ if (____0.options.help) {
217
+ res.set('help-info-content', 'Route Not Set File Path');
218
+ }
219
+ res.status(200);
220
+ _0xrrxo.endResponse(req, res);
221
+ return;
222
+ } else if (route.content) {
223
+ if (____0.options.help) {
224
+ res.set('help-info-content', 'Content From Route init');
225
+ }
226
+ res.status(200);
227
+ _0xrrxo.endResponse(req, res);
633
228
  }
634
- }
635
-
636
- if (!route.name.like(____0.strings[15]) && route.require.permissions.length > 0) {
637
- let ok = !0;
638
- route.require.permissions.forEach((permission) => {
639
- if (!____0.security.isUserHasPermissions(req, res, permission)) {
640
- ok = !1;
641
- }
642
- });
643
- if (!ok) {
644
- if (route.name.contains(____0.strings[16])) {
645
- res.status(401);
646
- return res.json({
647
- done: !1,
648
- error: ____0.strings[14],
649
- permissions: route.require.permissions,
229
+
230
+ if (typeof route.path == 'string') {
231
+ ____0.readFile(route.path, function (err, file) {
232
+ if (!err) {
233
+ route.content = file.content.toString('utf8');
234
+ if (route.encript && route.encript === '123') {
235
+ route.content = ____0.f1(route.content);
236
+ }
237
+ route.stat = file.stat;
238
+ if (route.masterPage) {
239
+ for (var i = 0; i < ____0.masterPages.length; i++) {
240
+ if (route.masterPage == ____0.masterPages[i].name) {
241
+ route.content = ____0.readFileSync(____0.masterPages[i].header) + route.content + ____0.readFileSync(____0.masterPages[i].footer);
242
+ break;
243
+ }
244
+ }
245
+ }
246
+
247
+ if (____0.options.help) {
248
+ res.set('help-info-content', 'Route Read File');
249
+ }
250
+
251
+ res.status(200);
252
+ _0xrrxo.endResponse(req, res);
253
+ } else {
254
+ if (____0.options.help) {
255
+ res.set('help-error', 'Route Error Read File');
256
+ }
257
+
258
+ res.status(404);
259
+ route.empty = !0;
260
+ _0xrrxo.endResponse(req, res);
261
+ return;
262
+ }
650
263
  });
651
- } else {
652
- if (route.require.permissions.includes('login')) {
653
- return res.redirect(____0.options.security.login_url);
654
- } else {
655
- res.status(401);
656
- return res.render(
657
- ____0.strings[12],
658
- {
659
- permissions: route.require.permissions.join(','),
660
- html: `${____0.strings[14]} : ${route.require.permissions.join(',')}`,
661
- },
662
- {
663
- parser: ____0.strings[17],
264
+ } else if (typeof route.path == 'object') {
265
+ ____0.readFiles(route.path, function (err, data) {
266
+ if (!err) {
267
+ if (____0.options.help) {
268
+ res.set('help-info-content', 'Route Read Files');
269
+ }
270
+
271
+ route.content = data.toString('utf8');
272
+
273
+ res.status(200);
274
+ route.path = route.path.join('&&');
275
+ _0xrrxo.endResponse(req, res);
276
+ } else {
277
+ if (____0.options.help) {
278
+ res.set('help-error', 'Route Error Read Files');
279
+ }
280
+
281
+ res.status(404);
282
+ route.empty = !0;
283
+ _0xrrxo.endResponse(req, res);
284
+ return;
664
285
  }
665
- );
666
- }
667
- }
668
- }
669
- }
670
- }
671
-
672
- route.callback(req, res);
673
- };
674
-
675
- ____0.validateServerRequest = async function (req, res, next) {
676
- next(req, res);
677
- };
678
-
679
- ____0.validateRequest = async function (req, res, next) {
680
- next(req, res);
681
- };
682
- ____0.validateRoute = async function (req, res, next) {
683
- next(req, res);
684
- };
685
-
686
- ____0.validateSession = async function (req, res, next) {
687
- next(req, res);
688
- };
689
-
690
- _0xrrxo.handleServer = async function (req, res) {
691
- ____0.validateServerRequest(req, res, (req, res) => {
692
- req.host = req.headers['host'] || '';
693
- req.origin = req.headers['origin'] || '';
694
- req.referer = req.headers['referer'] || '';
695
- req.domain = '';
696
- req.subDomain = '';
697
- req.obj = {};
698
- req.query = {};
699
- req.queryRaw = {};
700
- req.data = req.body = {};
701
- req.bodyRaw = '';
702
- req.params = {};
703
- req.paramsRaw = {};
704
- req.features = [];
705
-
706
- res.setTimeout(1000 * ____0.options.responseTimeout, () => {
707
- if (req.url.like('*api*')) {
708
- return res.json({
709
- done: false,
710
- error: ____0.strings[19],
711
- });
712
- } else {
713
- res.end(503);
286
+ });
714
287
  }
715
- });
716
-
717
- req.addFeature = function (name) {
718
- req.features.push(name);
719
- };
720
-
721
- req.hasFeature = function (name) {
722
- return req.features.some((f) => f.like(name));
723
- };
724
-
725
- req.removeFeature = function (name) {
726
- req.features.forEach((f, i) => {
727
- if (f.like(name)) {
728
- req.features.splice(i, 1);
729
- }
730
- });
731
- };
732
-
733
- req.getUserFinger = function () {
734
- let userFinger = {
735
- id: null,
736
- email: null,
737
- date: new Date(),
738
- ip: null,
739
- };
288
+ };
740
289
 
741
- if (req && req.session && req.session.user) {
742
- req.session.user.profile = req.session.user.profile || {};
743
- userFinger.id = req.session.user.id;
744
- userFinger.email = req.session.user.email;
745
- userFinger.name = req.session.user.profile.name || userFinger.email;
746
- userFinger.name_ar = req.session.user.profile.name_ar || userFinger.email;
747
- userFinger.name_en = req.session.user.profile.name_en || userFinger.email;
748
- userFinger.ip = req.ip;
749
- } else {
290
+ _0xrrxo.call = function (r, req, res, callback) {
291
+ callback =
292
+ callback ||
293
+ function (req, res) {
294
+ ____0.log('No CallBack set For : ', r);
295
+ res.end();
296
+ };
297
+ if (typeof r === 'string') {
298
+ r = {
299
+ name: r,
300
+ method: req.method,
301
+ };
750
302
  }
751
303
 
752
- return userFinger;
753
- };
304
+ let exists = false;
305
+ _0xrrxo.list.forEach((rr) => {
306
+ if (exists) {
307
+ return;
308
+ }
309
+ if ((rr.name == r.name || rr.nameRaw == r.name) && rr.method == r.method) {
310
+ exists = true;
311
+ req.route = rr;
312
+ rr.callback(req, res);
313
+ }
314
+ });
754
315
 
755
- req.word = function (name) {
756
- let w = ____0.word(name);
757
- if (!w.hostList) {
758
- return w[req.session.language.id] || name;
759
- } else {
760
- if ((w2 = w.hostList.find((h) => req.host.like(h.name)))) {
761
- return w2[req.session.language.id] || name;
762
- }
763
- }
764
- return w[req.session.language.id] || name;
765
- };
766
-
767
- res.code = null;
768
- req.remoteAddress = req.socket?.remoteAddress || '';
769
- req.acceptEncoding = req.headers[____0.strings[5]] ? req.headers[____0.strings[5]] : '';
770
- res.ip = req.ip = req.headers[____0.strings[6]] ? req.headers[____0.strings[6]] : req.remoteAddress?.replace('::ffff:', '');
771
- if (req.ip == '::1') {
772
- req.ip = '127.0.0.1';
773
- }
774
- res.ip2 = req.ip2 = req.socket?.localAddress.replace('::ffff:', '');
775
- res.port = req.port = req.socket?.remotePort;
776
- res.port2 = req.port2 = req.socket?.localPort;
777
- res.cookies = res.cookie = req.cookies = req.cookie = ____0.cookie(req, res, ____0);
778
-
779
- req.urlRaw = req.url;
780
- req.urlParserRaw = ____0.url.parse(req.urlRaw, !0);
781
- req.urlParser = ____0.url.parse(req.urlRaw.toLowerCase(), !0);
782
-
783
- res.set = (a, b, c) => {
784
- if (res.writeHeadEnabled === !1 || res.finished === !0 || res.headersSent) {
785
- return res;
316
+ if (!exists) {
317
+ callback(req, res);
786
318
  }
787
- if (typeof b == 'string') {
788
- res.headers = res.headers || [];
789
- res.headers[a] = b.toLowerCase();
790
- }
791
-
792
- res.setHeader(a, b, c);
793
- return res;
794
- };
795
-
796
- res.delete = res.remove = res.removeHeader;
797
- res.writeHead0 = res.writeHead;
798
- res.writeHeadEnabled = !0;
799
-
800
- res.writeHead = (code, obj) => {
801
- if (res.writeHeadEnabled === !1 || res.finished === !0) {
802
- return res;
319
+ };
320
+ _0xrrxo.off = function (r) {
321
+ if (!r) {
322
+ return;
803
323
  }
804
- res.cookie.write();
805
- res.writeHeadEnabled = !1;
806
- res.writeHead0(code, obj);
807
- return res;
808
- };
809
-
810
- res.ending = (time, ...data) => {
811
- if (!time) {
812
- time = 0;
324
+ if (typeof r == 'string') {
325
+ r = { name: r };
813
326
  }
814
- setTimeout(function () {
815
- res.end(...data);
816
- }, time);
817
- };
818
-
819
- res.end0 = res.end;
820
- res.end = function (arg1, arg2, arg3, arg4) {
821
- if (res.ended) {
822
- return;
327
+ if (!r.name.startsWith('/')) {
328
+ r.name = '/' + r.name;
823
329
  }
824
330
 
825
- if (typeof arg1 === 'number') {
826
- res.writeHead(arg1);
827
- return res.end(arg2, arg3, arg4);
828
- } else {
829
- if (res.headers === undefined || res.headers[____0.strings[7]] === undefined) {
830
- res.set(____0.strings[7], 'text/html');
831
- }
832
-
833
- if (
834
- arg1 &&
835
- res.headers &&
836
- res.headers[____0.strings[7]] &&
837
- (res.headers[____0.strings[7]].like('*text/css*') ||
838
- res.headers[____0.strings[7]].like('*application/javascript*') ||
839
- res.headers[____0.strings[7]].like('*text/html*') ||
840
- res.headers[____0.strings[7]].like('*text/plain*') ||
841
- res.headers[____0.strings[7]].like('*application/json*'))
842
- ) {
843
- if (req.acceptEncoding.like('*gzip*') && typeof arg1 === 'string') {
844
- res.set(____0.strings[8], 'gzip');
845
- res.set('Vary', ____0.strings[5]);
846
- arg1 = ____0.zlib.gzipSync(Buffer.from(arg1));
847
- } else if (req.acceptEncoding.like('*deflate*') && typeof arg1 === 'string') {
848
- res.set(____0.strings[8], 'deflate');
849
- res.set('Vary', ____0.strings[5]);
850
- arg1 = ____0.zlib.deflateSync(Buffer.from(arg1));
851
- } else {
852
- // ____0.log(typeof arg1)
331
+ for (let i = _0xrrxo.list.length; i--; ) {
332
+ let oldRoute = _0xrrxo.list[i];
333
+ if (r.name && r.method && oldRoute.name.like(r.name) && oldRoute.method.like(r.method)) {
334
+ _0xrrxo.list.splice(i, 1);
335
+ ____0.fsm.off(oldRoute.path);
336
+ } else if (r.name && r.method && oldRoute.nameRaw.like(r.name) && oldRoute.method.like(r.method)) {
337
+ _0xrrxo.list.splice(i, 1);
338
+ ____0.fsm.off(oldRoute.path);
339
+ } else if (r.name && oldRoute.name.like(r.name)) {
340
+ _0xrrxo.list.splice(i, 1);
341
+ ____0.fsm.off('*' + oldRoute.name.replace('/', '') + '*');
342
+ ____0.fsm.off(oldRoute.path);
343
+ } else if (r.name && oldRoute.nameRaw.like(r.name)) {
344
+ _0xrrxo.list.splice(i, 1);
345
+ ____0.fsm.off('*' + oldRoute.name.replace('/', '') + '*');
346
+ ____0.fsm.off(oldRoute.path);
347
+ } else if (r.method && oldRoute.method.like(r.method)) {
348
+ _0xrrxo.list.splice(i, 1);
349
+ ____0.fsm.off(oldRoute.path);
853
350
  }
854
- }
855
-
856
- res.writeHead(res.code || res.statusCode || 200);
857
- arg1 = arg1 || ' ';
858
- res.ended = true;
859
- return res.end0(arg1, arg2, arg3, arg4);
860
351
  }
861
- };
862
-
863
- res.status = (code) => {
864
- if (!res.code) {
865
- res.code = code || 200;
866
- }
867
- return res;
868
- };
869
-
870
- res.error = (code) => {
871
- res.status(code || 404).end();
872
- };
873
-
874
- res.download2 = (path, name) => {
875
- if (____0.isFileExistsSync(path)) {
876
- var stat = ____0.fileStatSync(path);
877
- if (stat && stat.isFile()) {
878
- res.writeHead(200, {
879
- 'Content-Type': ____0.getContentType(path),
880
- 'Content-Length': stat.size,
881
- 'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
882
- });
883
- var readStream = ____0.fs.createReadStream(path);
884
- readStream.on('end', function () {
885
- readStream.close();
352
+ };
353
+ _0xrrxo.add = function (r, callback) {
354
+ if (Array.isArray(r)) {
355
+ r.forEach((r2) => {
356
+ _0xrrxo.add(r2, callback);
886
357
  });
887
- res.on(____0.strings[10], function () {
888
- readStream.close();
358
+ return;
359
+ }
360
+ if (r && r.name && Array.isArray(r.name)) {
361
+ r.name.forEach((r2) => {
362
+ let r3 = { ...r };
363
+ r3.name = r2;
364
+ _0xrrxo.onREQUEST(r3, r.callback);
889
365
  });
890
- readStream.pipe(res);
891
- } else {
892
- res.error();
893
- }
894
- } else {
895
- res.error();
366
+ return;
896
367
  }
897
- };
898
-
899
- res.download = function (path, name) {
900
- if (____0.isFileExistsSync(path)) {
901
- const stat = ____0.fileStatSync(path);
902
- if (stat && stat.isFile()) {
903
- const fileSize = stat.size;
904
- const range = req.headers.range;
905
- if (range) {
906
- const parts = range.replace(/bytes=/, '').split('-');
907
- const start = parseInt(parts[0], 10);
908
- const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
909
-
910
- const chunksize = end - start + 1;
911
- const readStream = ____0.fs.createReadStream(path, {
912
- start,
913
- end,
914
- });
915
- readStream.on('end', function () {
916
- readStream.close();
917
- });
918
- res.on(____0.strings[10], function () {
919
- readStream.close();
920
- });
921
- res.writeHead(206, {
922
- 'Content-Range': `bytes ${start}-${end}/${fileSize}`,
923
- 'Accept-Ranges': 'bytes',
924
- 'Content-Length': chunksize,
925
- 'Content-Type': ____0.getContentType(path),
926
- });
927
- readStream.pipe(res);
368
+ let route = {};
369
+
370
+ if (typeof r == 'string') {
371
+ route.name = r.toLowerCase();
372
+ route.nameRaw = r;
373
+ route.public = ____0.options.public || false;
374
+ route.method = 'GET';
375
+ route.path = null;
376
+ route.parser = 'static';
377
+ route.parserDir = ____0.dir;
378
+ route.count = 0;
379
+ route.cache = !0;
380
+ route.hide = !1;
381
+ route.compress = !1;
382
+ route.encript = !1;
383
+ route.shared = !1;
384
+ route.content = null;
385
+ route.headers = null;
386
+ route.map = [];
387
+ route.callback = callback ?? _0xrrxo.defaultCallback;
388
+ if (route.public) {
389
+ route.require = {
390
+ features: [],
391
+ permissions: [],
392
+ };
928
393
  } else {
929
- const readStream = ____0.fs.createReadStream(path);
930
- readStream.on('end', function () {
931
- readStream.close();
932
- });
933
- res.on(____0.strings[10], function () {
934
- readStream.close();
935
- });
936
-
937
- res.writeHead(200, {
938
- 'Content-Length': fileSize,
939
- 'Content-Type': ____0.getContentType(path),
940
- 'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
941
- });
942
- ____0.fs.createReadStream(path).pipe(res);
394
+ route.require = ____0.options.require;
395
+ route.default = ____0.options.defaults;
943
396
  }
944
- } else {
945
- res.error();
946
- }
947
397
  } else {
948
- res.error();
949
- }
950
- };
398
+ route.name = r.name.toLowerCase();
399
+ route.nameRaw = r.name;
400
+ route.public = r.public ?? (____0.options.public || false);
401
+ route.method = r.method || 'GET';
402
+ route.path = r.path || null;
403
+ route.lang = r.lang || null;
404
+ route.content = r.content;
405
+ route.headers = r.headers;
406
+ route.parser = r.parser || 'static';
407
+ route.parserDir = r.parserDir || ____0.dir;
408
+ route.masterPage = r.masterPage || null;
409
+ route.overwrite = r.overwrite ?? !1;
410
+ route.cache = r.cache ?? !0;
411
+ route.count = r.count || 0;
412
+ route.hide = r.hide ?? !1;
413
+ route.compress = r.compress ?? !1;
414
+ route.encript = r.encript ?? !1;
415
+ route.shared = r.shared ?? !1;
416
+ route.map = r.map || [];
417
+ route.callback = callback || r.callback || _0xrrxo.defaultCallback;
418
+
419
+ if (route.public) {
420
+ route.require = {
421
+ features: [],
422
+ permissions: [],
423
+ };
424
+ } else {
425
+ route.require = r.require ?? ____0.options.require;
426
+ route.require.features = route.require.features ?? ____0.options.require.features;
427
+ route.require.permissions = route.require.permissions ?? ____0.options.require.permissions;
951
428
 
952
- res.html = res.render = function (file, _data = null, options = {}) {
953
- let filePath = '';
954
- if (typeof file === 'object') {
955
- filePath = file.path;
956
- options = { ...options, ...file };
957
- } else {
958
- filePath = file;
429
+ route.default = r.default ?? ____0.options.defaults;
430
+ route.default.features = route.default.features ?? ____0.options.defaults.features;
431
+ route.default.permissions = route.default.permissions ?? ____0.options.defaults.permissions;
432
+ }
959
433
  }
960
434
 
961
- if ((response = ____0.sharedList.find((s) => s.host == req.host && s.filePath == filePath && s.url == req.url))) {
962
- res.headers = response.headers;
963
- res.code = response.code;
964
- res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length + ' -count=' + req.route.count);
965
- return res.end(response.content, response.encode);
435
+ if (!route.name.startsWith('/')) {
436
+ route.name = '/' + route.name;
437
+ route.nameRaw = '/' + route.nameRaw;
966
438
  }
967
- ____0.fsm.getContent(filePath, (content) => {
968
- if (!content) {
969
- if (_data && _data.html) {
970
- return res.status(404).htmlContent(_data.html);
971
- } else {
972
- return res.status(404).end();
973
- }
974
- }
975
439
 
976
- req.content = content;
977
- req.data = { ...req.data, ..._data };
978
- let route = { ...req.route, ...options };
440
+ route.name = route.name.replace('//', '/');
441
+ route.nameRaw = route.nameRaw.replace('//', '/');
979
442
 
980
- if (route.encript == '123') {
981
- req.content = ____0.f1(req.content);
982
- }
443
+ let arr = route.name.split('/');
444
+ let arr0 = route.nameRaw.split('/');
983
445
 
984
- if (route.parser) {
985
- req.content = ____0.parser(req, res, ____0, route).html(req.content);
986
- }
446
+ for (var i = 0; i < arr.length; i++) {
447
+ var s = arr[i];
448
+ var s0 = arr0[i];
987
449
 
988
- if (route.compress) {
989
- req.content = req.content.replace(/\r?\n|\r/g, ' ').replace(/\s+/g, ' ');
990
- }
450
+ if (s.startsWith(':')) {
451
+ arr[i] = '*';
452
+ let name = s.replace(':', '');
453
+ let nameRaw = s0.replace(':', '');
991
454
 
992
- res.status(options.code || 200);
993
- if (filePath.endsWith('.css')) {
994
- res.set(____0.strings[7], 'text/css');
995
- if (____0.options.cache.enabled && route.cache) {
996
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.css);
997
- }
998
- } else if (filePath.endsWith('.js')) {
999
- res.set(____0.strings[7], 'application/javascript');
1000
- if (____0.options.cache.enabled && route.cache) {
1001
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.js);
1002
- }
1003
- } else if (filePath.endsWith('.html')) {
1004
- res.set(____0.strings[7], 'text/html');
1005
- if (____0.options.cache.enabled && route.cache) {
1006
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.html);
1007
- }
1008
- } else if (filePath.endsWith('.txt')) {
1009
- res.set(____0.strings[7], 'text/plain');
1010
- if (____0.options.cache.enabled && route.cache) {
1011
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.txt);
1012
- }
1013
- } else if (filePath.endsWith('.json')) {
1014
- res.set(____0.strings[7], 'application/json');
1015
- if (____0.options.cache.enabled && route.cache) {
1016
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.json);
1017
- }
1018
- } else if (filePath.endsWith('.xml')) {
1019
- res.set(____0.strings[7], 'text/xml');
1020
- if (____0.options.cache.enabled && route.cache) {
1021
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.xml);
1022
- }
1023
- } else if (filePath.endsWith('.woff2')) {
1024
- res.set(____0.strings[7], 'application/font-woff2');
1025
- if (____0.options.cache.enabled && route.cache) {
1026
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1027
- }
1028
- } else if (filePath.endsWith('.woff')) {
1029
- res.set(____0.strings[7], 'application/font-woff');
1030
- if (____0.options.cache.enabled && route.cache) {
1031
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1032
- }
1033
- } else if (filePath.endsWith('.ttf')) {
1034
- res.set(____0.strings[7], 'application/font-ttf');
1035
- if (____0.options.cache.enabled && route.cache) {
1036
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1037
- }
1038
- } else if (filePath.endsWith('.svg')) {
1039
- res.set(____0.strings[7], 'application/font-svg');
1040
- if (____0.options.cache.enabled && route.cache) {
1041
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1042
- }
1043
- } else if (filePath.endsWith('.otf')) {
1044
- res.set(____0.strings[7], 'application/font-otf');
1045
- if (____0.options.cache.enabled && route.cache) {
1046
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1047
- }
1048
- } else if (filePath.endsWith('.eot')) {
1049
- res.set(____0.strings[7], 'application/font-eot');
1050
- if (____0.options.cache.enabled && route.cache) {
1051
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1052
- }
1053
- } else if (filePath.endsWith('.gif')) {
1054
- res.set(____0.strings[7], 'image/gif');
1055
- if (____0.options.cache.enabled && route.cache) {
1056
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1057
- }
1058
- } else if (filePath.endsWith('.png')) {
1059
- res.set(____0.strings[7], 'image/png');
1060
- if (____0.options.cache.enabled && route.cache) {
1061
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1062
- }
1063
- } else if (filePath.endsWith('.jpg')) {
1064
- res.set(____0.strings[7], 'image/jpg');
1065
- if (____0.options.cache.enabled && route.cache) {
1066
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1067
- }
1068
- } else if (filePath.endsWith('.jpeg')) {
1069
- res.set(____0.strings[7], 'image/jpeg');
1070
- if (____0.options.cache.enabled && route.cache) {
1071
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1072
- }
1073
- } else if (filePath.endsWith('.ico')) {
1074
- res.set(____0.strings[7], 'image/ico');
1075
- if (____0.options.cache.enabled && route.cache) {
1076
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1077
- }
1078
- } else if (filePath.endsWith('.bmp')) {
1079
- res.set(____0.strings[7], 'image/bmp');
1080
- if (____0.options.cache.enabled && route.cache) {
1081
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1082
- }
1083
- } else if (filePath.endsWith('.webp')) {
1084
- res.set(____0.strings[7], 'image/webp');
1085
- if (____0.options.cache.enabled && route.cache) {
1086
- res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
455
+ route.map.push({
456
+ index: i,
457
+ name: name,
458
+ isLower: !1,
459
+ });
460
+ if (name !== nameRaw) {
461
+ route.map.push({
462
+ index: i,
463
+ name: nameRaw,
464
+ isLower: !0,
465
+ });
466
+ }
1087
467
  }
1088
- }
468
+ }
469
+ try {
470
+ route.name = arr.join('/');
471
+ if (typeof route.path == 'string' && ____0.fs.lstatSync(route.path).isDirectory()) {
472
+ ____0.fs.readdir(route.path, (err, files) => {
473
+ files.forEach((file) => {
474
+ let r2 = { ...route };
475
+ if (route.name.endsWith('/')) {
476
+ r2.name = route.name + file;
477
+ } else {
478
+ r2.name = route.name + '/' + file;
479
+ }
480
+
481
+ r2.path = route.path + '/' + file;
482
+ r2.is_dynamic = !0;
483
+ _0xrrxo.add(r2);
484
+ });
485
+ });
486
+ } else {
487
+ if (!route.name.startsWith('/')) {
488
+ route.name = '/' + route.name;
489
+ }
1089
490
 
1090
- let response = {
1091
- host: req.host,
1092
- url: req.url,
1093
- filePath: filePath,
1094
- content: req.content,
1095
- encode: ____0.getFileEncode(filePath),
1096
- headers: res.headers,
1097
- code: res.code,
1098
- };
491
+ route.name = encodeURI(route.name);
492
+ let index = _0xrrxo.list.findIndex((rr) => rr.name == route.name && rr.method == route.method);
493
+ if (index === -1) {
494
+ _0xrrxo.list.push(route);
495
+ } else if (!route.overwrite) {
496
+ if (route.name.like('*api/*')) {
497
+ ____0.log('[ Duplicate API ] ' + route.name);
498
+ } else {
499
+ ____0.log('[ Duplicate Route ] ' + route.name);
500
+ }
501
+ } else {
502
+ _0xrrxo.list[index] = route;
503
+ }
504
+ }
505
+ } catch (err) {
506
+ ____0.log(err);
507
+ return null;
508
+ }
509
+ };
1099
510
 
1100
- if (options.shared && !____0.sharedList.some((s) => s.host == req.host && s.filePath == response.filePath && s.url == response.url)) {
1101
- ____0.sharedList.push(response);
1102
- }
511
+ _0xrrxo.onREQUEST = function (type, r, callback) {
512
+ if (Array.isArray(r)) {
513
+ r.forEach((r2) => {
514
+ _0xrrxo.onREQUEST(type, r2, callback);
515
+ });
516
+ return;
517
+ }
518
+ let route = {};
519
+ if (typeof r == 'string') {
520
+ route = {
521
+ name: r,
522
+ method: type,
523
+ callback: callback || _0xrrxo.defaultCallback,
524
+ };
525
+ } else {
526
+ route = r;
1103
527
 
1104
- res.end(response.content, response.encode);
1105
- });
1106
- };
1107
-
1108
- res.txt = (name, _data) => {
1109
- ____0.fsm.getContent(name, (content) => {
1110
- if (!content) {
1111
- return res.status(404).end();
1112
- }
1113
- req.route.content = content;
1114
- if (req.route.encript === '123') {
1115
- req.route.content = ____0.f1(req.route.content);
1116
- }
1117
- req.data = { ...req.data, ..._data };
1118
- req.route.parser = 'txt';
1119
- let out = ____0.parser(req, res, ____0, req.route).txt(req.route.content);
1120
- res.set(____0.strings[7], 'text/plain');
1121
- res.status(200).end(out);
1122
- });
1123
- };
1124
-
1125
- res.css = (name, _data) => {
1126
- ____0.fsm.getContent(name, (content) => {
1127
- if (!content) {
1128
- return res.status(404).end();
1129
- }
1130
- req.route.content = content;
1131
- if (req.route.encript === '123') {
1132
- req.route.content = ____0.f1(req.route.content);
1133
- }
1134
- req.data = { ...req.data, ..._data };
1135
- req.route.parser = 'css';
1136
- let out = ____0.parser(req, res, ____0, req.route).css(req.route.content);
1137
- res.set(____0.strings[7], 'text/css');
1138
- res.status(200).end(out);
1139
- });
1140
- };
1141
-
1142
- res.js = (name, _data) => {
1143
- ____0.fsm.getContent(name, (content) => {
1144
- if (!content) {
1145
- return res.status(404).end();
1146
- }
1147
- req.route.content = content;
1148
- if (req.route.encript === '123') {
1149
- req.route.content = ____0.f1(req.route.content);
1150
- }
1151
- req.data = { ...req.data, ..._data };
1152
- req.route.parser = 'js';
1153
- let out = ____0.parser(req, res, ____0, req.route).js(req.route.content);
1154
- res.set(____0.strings[7], 'text/javascript');
1155
- res.status(200).end(out);
1156
- });
1157
- };
1158
-
1159
- res.jsonFile = (name, _data) => {
1160
- ____0.fsm.getContent(name, (content) => {
1161
- if (!content) {
1162
- return res.status(404).end();
1163
- }
1164
- req.route.content = content;
1165
- if (req.route.encript === '123') {
1166
- req.route.content = ____0.f1(req.route.content);
1167
- }
1168
- req.data = { ...req.data, ..._data };
1169
- req.route.parser = 'json';
1170
- let out = ____0.parser(req, res, ____0, req.route).html(req.route.content);
1171
- res.set(____0.strings[7], 'application/json');
1172
- res.status(200).end(out);
1173
- });
1174
- };
1175
-
1176
- res.htmlContent =
1177
- res.send =
1178
- res.sendHTML =
1179
- (text) => {
1180
- if (typeof text === 'string') {
1181
- res.set(____0.strings[7], 'text/html');
1182
- res.status(200).end(text);
1183
- } else {
1184
- res.json(text);
528
+ if (Array.isArray(r.name)) {
529
+ r.name.forEach((n) => {
530
+ let sub_route = { ...route };
531
+ sub_route.name = n;
532
+ _0xrrxo.onREQUEST(type, sub_route, callback);
533
+ });
534
+ return;
1185
535
  }
1186
- };
1187
- res.textContent = res.sendTEXT = (text) => {
1188
- if (typeof text === 'string') {
1189
- res.set(____0.strings[7], 'text/plain');
1190
- res.status(200).end(text);
1191
- } else {
1192
- res.json(text);
536
+ route.callback = route.callback || callback || _0xrrxo.defaultCallback;
1193
537
  }
1194
- };
1195
- res.json = (obj, time) => {
1196
- if (typeof obj === 'string') {
1197
- return res.jsonFile(obj);
1198
- } else {
1199
- res.set(____0.strings[7], 'application/json');
1200
- obj = ____0.toJson(obj);
1201
- res.status(200).ending(time || 0, obj);
1202
- obj = null;
1203
- return res;
538
+ route.method = type;
539
+ _0xrrxo.add(route);
540
+ };
541
+
542
+ _0xrrxo.onGET = function (r, callback) {
543
+ _0xrrxo.onREQUEST('GET', r, callback);
544
+ };
545
+ _0xrrxo.onPOST = function (r, callback) {
546
+ _0xrrxo.onREQUEST('POST', r, callback);
547
+ };
548
+ _0xrrxo.onPUT = function (r, callback) {
549
+ _0xrrxo.onREQUEST('PUT', r, callback);
550
+ };
551
+ _0xrrxo.onDELETE = function (r, callback) {
552
+ _0xrrxo.onREQUEST('DELETE', r, callback);
553
+ };
554
+
555
+ _0xrrxo.onTEST = function (r, callback) {
556
+ _0xrrxo.onREQUEST('TEST', r, callback);
557
+ };
558
+
559
+ _0xrrxo.onVIEW = function (r, callback) {
560
+ _0xrrxo.onREQUEST('VIEW', r, callback);
561
+ };
562
+ _0xrrxo.onOPTIONS = function (r, callback) {
563
+ _0xrrxo.onREQUEST('OPTIONS', r, callback);
564
+ };
565
+ _0xrrxo.onPATCH = function (r, callback) {
566
+ _0xrrxo.onREQUEST('PATCH', r, callback);
567
+ };
568
+ _0xrrxo.onCOPY = function (r, callback) {
569
+ _0xrrxo.onREQUEST('COPY', r, callback);
570
+ };
571
+ _0xrrxo.onHEAD = function (r, callback) {
572
+ _0xrrxo.onREQUEST('HEAD', r, callback);
573
+ };
574
+ _0xrrxo.onLINK = function (r, callback) {
575
+ _0xrrxo.onREQUEST('LINK', r, callback);
576
+ };
577
+ _0xrrxo.onUNLINK = function (r, callback) {
578
+ _0xrrxo.onREQUEST('UNLINK', r, callback);
579
+ };
580
+ _0xrrxo.onPURGE = function (r, callback) {
581
+ _0xrrxo.onREQUEST('PURGE', r, callback);
582
+ };
583
+ _0xrrxo.onLOCK = function (r, callback) {
584
+ _0xrrxo.onREQUEST('LOCK', r, callback);
585
+ };
586
+ _0xrrxo.onUNLOCK = function (r, callback) {
587
+ _0xrrxo.onREQUEST('UNLOCK', r, callback);
588
+ };
589
+ _0xrrxo.onPROPFIND = function (r, callback) {
590
+ _0xrrxo.onREQUEST('PROPFIND', r, callback);
591
+ };
592
+
593
+ _0xrrxo.onALL = _0xrrxo.onANY = function (r, callback) {
594
+ _0xrrxo.onREQUEST('*', r, callback);
595
+ };
596
+
597
+ _0xrrxo.handleRoute = async function (req, res, route) {
598
+ if (route.language) {
599
+ req.session.language = { ...route.language };
1204
600
  }
1205
- };
1206
-
1207
- res.redirect = (url, code = 302) => {
1208
- res.set('Location', url);
1209
- res.status(code).end();
1210
- };
1211
-
1212
- res.set('CharSet', 'UTF-8');
1213
- res.set('Access-Control-Allow-Credentials', 'true');
1214
- res.set('Access-Control-Allow-Headers', req.headers['access-control-request-headers'] || 'Origin, X-Requested-With, Content-Type, Accept , Access-Token , Authorization');
1215
- res.set('Access-Control-Allow-Methods', req.headers['access-control-request-method'] || 'POST,GET,DELETE,PUT,OPTIONS,VIEW,HEAD,CONNECT,TRACE');
1216
- res.set('Access-Control-Allow-Origin', req.origin || req.referer || '*');
1217
-
1218
- ____0.validateRequest(req, res, (req, res) => {
1219
- if (____0.options.www === false && req.host.contains('www')) {
1220
- res.redirect('//' + req.host.replace('www.', '') + req.url, 301);
1221
- return;
601
+
602
+ if (route.lang) {
603
+ req.session.language.id = route.lang;
1222
604
  }
1223
605
 
1224
- if (!req.urlParser.pathname.like(____0.strings[0])) {
1225
- if (!____0._0_a405) {
1226
- res.status(405);
1227
- res.end();
1228
- return;
1229
- }
1230
-
1231
- if (!____0._0_ar2_0_) {
1232
- res.set(____0.strings[1], 'true');
1233
- res.status(402);
1234
- if (req.url.like('*api*')) {
1235
- return res.json({
1236
- done: false,
1237
- error: ____0.strings[3],
1238
- });
1239
- } else {
1240
- return res.render(
1241
- ____0.strings[2],
1242
- {
1243
- html: ____0.strings[3],
1244
- },
1245
- {
1246
- parser: ____0.strings[17],
606
+ if (!route.public) {
607
+ if (!route.name.like(____0.strings[15]) && route.require.features.length > 0) {
608
+ let ok = !0;
609
+ route.require.features.forEach((feature) => {
610
+ if (!req.hasFeature(feature)) {
611
+ ok = !1;
612
+ }
613
+ });
614
+ if (!ok) {
615
+ res.status(401);
616
+ if (route.name.contains(____0.strings[16])) {
617
+ return res.json({
618
+ done: !1,
619
+ error: ____0.strings[13],
620
+ features: route.require.features,
621
+ });
622
+ } else
623
+ return res.render(
624
+ ____0.strings[11],
625
+ {
626
+ features: route.require.features,
627
+ html: ` ${____0.strings[13]} : ${route.require.features.join(',')}`,
628
+ },
629
+ {
630
+ parser: ____0.strings[17],
631
+ }
632
+ );
1247
633
  }
1248
- );
1249
634
  }
1250
- }
1251
- }
1252
635
 
1253
- let findRouteIndex = _0xrrxo.list.findIndex((r) => req.method.toLowerCase().like(r.method.toLowerCase()) && req.urlParser.pathname.like(r.name));
1254
- if (findRouteIndex !== -1) {
1255
- if (!_0xrrxo.list[findRouteIndex].count) {
1256
- _0xrrxo.list[findRouteIndex].count = 0;
1257
- }
1258
- _0xrrxo.list[findRouteIndex].count++;
1259
- if (____0.options.help) {
1260
- res.set('help-request-count', _0xrrxo.list[findRouteIndex].count);
1261
- }
1262
-
1263
- req.route = _0xrrxo.list[findRouteIndex];
1264
-
1265
- req.urlParser.arr = req.urlParser.pathname.split('/');
1266
- req.urlParserRaw.arr = req.urlParserRaw.pathname.split('/');
1267
-
1268
- for (let i = 0; i < req.route.map.length; i++) {
1269
- let map = req.route.map[i];
1270
- if (typeof req.urlParser.arr[map.index] === 'string') {
1271
- try {
1272
- req.params[map.name] = decodeURIComponent(req.urlParser.arr[map.index].replace(/\+/g, ' '));
1273
- } catch (error) {
1274
- req.params[map.name] = req.urlParser.arr[map.index].replace(/\+/g, ' ');
1275
- }
1276
- req.paramsRaw[map.name] = req.urlParserRaw.arr[map.index];
636
+ if (!route.name.like(____0.strings[15]) && route.require.permissions.length > 0) {
637
+ let ok = !0;
638
+ route.require.permissions.forEach((permission) => {
639
+ if (!____0.security.isUserHasPermissions(req, res, permission)) {
640
+ ok = !1;
641
+ }
642
+ });
643
+ if (!ok) {
644
+ if (route.name.contains(____0.strings[16])) {
645
+ res.status(401);
646
+ return res.json({
647
+ done: !1,
648
+ error: ____0.strings[14],
649
+ permissions: route.require.permissions,
650
+ });
651
+ } else {
652
+ if (route.require.permissions.includes('login')) {
653
+ return res.redirect(____0.options.security.login_url);
654
+ } else {
655
+ res.status(401);
656
+ return res.render(
657
+ ____0.strings[12],
658
+ {
659
+ permissions: route.require.permissions.join(','),
660
+ html: `${____0.strings[14]} : ${route.require.permissions.join(',')}`,
661
+ },
662
+ {
663
+ parser: ____0.strings[17],
664
+ }
665
+ );
666
+ }
667
+ }
668
+ }
1277
669
  }
1278
- }
1279
- req.session = {
1280
- $save: () => {},
1281
- accessToken: 'SHARED',
1282
- language: ____0.options.language || { id: 'En', dir: 'ltr', text: 'left' },
1283
- lang: ____0.options.language?.id || ____0.options.lang || 'En',
1284
- };
1285
-
1286
- req.query = req.urlParser.query;
1287
- req.queryRaw = req.urlParserRaw.query;
1288
-
1289
- ____0.validateRoute(req, res, (req, res) => {
1290
- if (!req.method.toLowerCase().like('get') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].match(/urlencoded/i)) {
1291
- req.on('data', function (data) {
1292
- req.bodyRaw += data;
1293
- });
1294
- req.on('end', function () {
1295
- req.dataRaw = req.bodyRaw;
1296
- req.data = req.body = ____0.querystring.parse(req.bodyRaw);
1297
- if (____0.options.session.enabled) {
1298
- ____0.session(req, res, ____0, function (session) {
1299
- req.session = session;
1300
- ____0.validateSession(req, res, (req, res) => {
1301
- _0xrrxo.handleRoute(req, res, req.route);
670
+ }
671
+
672
+ route.callback(req, res);
673
+ };
674
+
675
+ ____0.validateServerRequest = async function (req, res, next) {
676
+ next(req, res);
677
+ };
678
+
679
+ ____0.validateRequest = async function (req, res, next) {
680
+ next(req, res);
681
+ };
682
+ ____0.validateRoute = async function (req, res, next) {
683
+ next(req, res);
684
+ };
685
+
686
+ ____0.validateSession = async function (req, res, next) {
687
+ next(req, res);
688
+ };
689
+
690
+ _0xrrxo.handleServer = async function (req, res) {
691
+ ____0.validateServerRequest(req, res, (req, res) => {
692
+ req.host = req.headers['host'] || '';
693
+ req.origin = req.headers['origin'] || '';
694
+ req.referer = req.headers['referer'] || '';
695
+ req.domain = '';
696
+ req.subDomain = '';
697
+ req.obj = {};
698
+ req.query = {};
699
+ req.queryRaw = {};
700
+ req.data = req.body = {};
701
+ req.bodyRaw = '';
702
+ req.params = {};
703
+ req.paramsRaw = {};
704
+ req.features = [];
705
+
706
+ res.setTimeout(1000 * ____0.options.responseTimeout, () => {
707
+ if (req.url.like('*api*')) {
708
+ return res.json({
709
+ done: false,
710
+ error: ____0.strings[19],
1302
711
  });
1303
- });
1304
712
  } else {
1305
- _0xrrxo.handleRoute(req, res, req.route);
713
+ res.end(503);
1306
714
  }
1307
- });
1308
- } else if (req.method.contains('post') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].contains('multipart')) {
1309
- let form = ____0.formidable({
1310
- multiples: !0,
1311
- uploadDir: ____0.options.upload_dir,
1312
- });
1313
-
1314
- form.parse(req, (err, fields, files) => {
1315
- if (err) {
1316
- ____0.log(err);
715
+ });
716
+
717
+ req.addFeature = function (name) {
718
+ req.features.push(name);
719
+ };
720
+
721
+ req.hasFeature = function (name) {
722
+ return req.features.some((f) => f.like(name));
723
+ };
724
+
725
+ req.removeFeature = function (name) {
726
+ req.features.forEach((f, i) => {
727
+ if (f.like(name)) {
728
+ req.features.splice(i, 1);
729
+ }
730
+ });
731
+ };
732
+
733
+ req.getUserFinger = function () {
734
+ let userFinger = {
735
+ id: null,
736
+ email: null,
737
+ date: new Date(),
738
+ ip: null,
739
+ };
740
+
741
+ if (req && req.session && req.session.user) {
742
+ req.session.user.profile = req.session.user.profile || {};
743
+ userFinger.id = req.session.user.id;
744
+ userFinger.email = req.session.user.email;
745
+ userFinger.name = req.session.user.profile.name || userFinger.email;
746
+ userFinger.name_ar = req.session.user.profile.name_ar || userFinger.email;
747
+ userFinger.name_en = req.session.user.profile.name_en || userFinger.email;
748
+ userFinger.ip = req.ip;
749
+ } else {
1317
750
  }
1318
- req.form = { err, fields, files };
1319
- req.data = req.body = fields || {};
1320
- req.files = files;
1321
- if (____0.options.session.enabled) {
1322
- ____0.session(req, res, ____0, function (session) {
1323
- req.session = session;
1324
- ____0.validateSession(req, res, (req, res) => {
1325
- _0xrrxo.handleRoute(req, res, req.route);
1326
- });
1327
- });
751
+
752
+ return userFinger;
753
+ };
754
+
755
+ req.word = function (name) {
756
+ let w = ____0.word(name);
757
+ if (!w.hostList) {
758
+ return w[req.session.language.id] || name;
1328
759
  } else {
1329
- _0xrrxo.handleRoute(req, res, req.route);
760
+ if ((w2 = w.hostList.find((h) => req.host.like(h.name)))) {
761
+ return w2[req.session.language.id] || name;
762
+ }
1330
763
  }
1331
- });
1332
-
1333
- return;
1334
- } else if (!req.method.toLowerCase().like('get') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].match(/json/i)) {
1335
- req.on('data', function (data) {
1336
- req.bodyRaw += data;
1337
- });
1338
- req.on('end', function () {
1339
- req.dataRaw = req.bodyRaw;
1340
- req.data = req.body = ____0.fromJson(req.bodyRaw);
1341
- if (____0.options.session.enabled) {
1342
- ____0.session(req, res, ____0, function (session) {
1343
- req.session = session;
1344
- ____0.validateSession(req, res, (req, res) => {
1345
- _0xrrxo.handleRoute(req, res, req.route);
1346
- });
1347
- });
764
+ return w[req.session.language.id] || name;
765
+ };
766
+
767
+ res.code = null;
768
+ req.remoteAddress = req.socket?.remoteAddress || '';
769
+ req.acceptEncoding = req.headers[____0.strings[5]] ? req.headers[____0.strings[5]] : '';
770
+ res.ip = req.ip = req.headers[____0.strings[6]] ? req.headers[____0.strings[6]] : req.remoteAddress?.replace('::ffff:', '');
771
+ if (req.ip == '::1') {
772
+ req.ip = '127.0.0.1';
773
+ }
774
+ res.ip2 = req.ip2 = req.socket?.localAddress.replace('::ffff:', '');
775
+ res.port = req.port = req.socket?.remotePort;
776
+ res.port2 = req.port2 = req.socket?.localPort;
777
+ res.cookies = res.cookie = req.cookies = req.cookie = ____0.cookie(req, res, ____0);
778
+
779
+ req.urlRaw = req.url;
780
+ req.urlParserRaw = ____0.url.parse(req.urlRaw, !0);
781
+ req.urlParser = ____0.url.parse(req.urlRaw.toLowerCase(), !0);
782
+
783
+ res.set = (a, b, c) => {
784
+ if (res.writeHeadEnabled === !1 || res.finished === !0 || res.headersSent) {
785
+ return res;
786
+ }
787
+ if (typeof b == 'string') {
788
+ res.headers = res.headers || [];
789
+ res.headers[a] = b.toLowerCase();
790
+ }
791
+
792
+ res.setHeader(a, b, c);
793
+ return res;
794
+ };
795
+
796
+ res.delete = res.remove = res.removeHeader;
797
+ res.writeHead0 = res.writeHead;
798
+ res.writeHeadEnabled = !0;
799
+
800
+ res.writeHead = (code, obj) => {
801
+ if (res.writeHeadEnabled === !1 || res.finished === !0) {
802
+ return res;
803
+ }
804
+ res.cookie.write();
805
+ res.writeHeadEnabled = !1;
806
+ res.writeHead0(code, obj);
807
+ return res;
808
+ };
809
+
810
+ res.ending = (time, ...data) => {
811
+ if (!time) {
812
+ time = 0;
813
+ }
814
+ setTimeout(function () {
815
+ res.end(...data);
816
+ }, time);
817
+ };
818
+
819
+ res.end0 = res.end;
820
+ res.end = function (arg1, arg2, arg3, arg4) {
821
+ if (res.ended) {
822
+ return;
823
+ }
824
+
825
+ if (typeof arg1 === 'number') {
826
+ res.writeHead(arg1);
827
+ return res.end(arg2, arg3, arg4);
1348
828
  } else {
1349
- _0xrrxo.handleRoute(req, res, req.route);
829
+ if (res.headers === undefined || res.headers[____0.strings[7]] === undefined) {
830
+ res.set(____0.strings[7], 'text/html');
831
+ }
832
+
833
+ if (
834
+ arg1 &&
835
+ res.headers &&
836
+ res.headers[____0.strings[7]] &&
837
+ (res.headers[____0.strings[7]].like('*text/css*') ||
838
+ res.headers[____0.strings[7]].like('*application/javascript*') ||
839
+ res.headers[____0.strings[7]].like('*text/html*') ||
840
+ res.headers[____0.strings[7]].like('*text/plain*') ||
841
+ res.headers[____0.strings[7]].like('*application/json*'))
842
+ ) {
843
+ if (req.acceptEncoding.like('*gzip*') && typeof arg1 === 'string') {
844
+ res.set(____0.strings[8], 'gzip');
845
+ res.set('Vary', ____0.strings[5]);
846
+ arg1 = ____0.zlib.gzipSync(Buffer.from(arg1));
847
+ } else if (req.acceptEncoding.like('*deflate*') && typeof arg1 === 'string') {
848
+ res.set(____0.strings[8], 'deflate');
849
+ res.set('Vary', ____0.strings[5]);
850
+ arg1 = ____0.zlib.deflateSync(Buffer.from(arg1));
851
+ } else {
852
+ // ____0.log(typeof arg1)
853
+ }
854
+ }
855
+
856
+ res.writeHead(res.code || res.statusCode || 200);
857
+ arg1 = arg1 || ' ';
858
+ res.ended = true;
859
+ return res.end0(arg1, arg2, arg3, arg4);
1350
860
  }
1351
- });
1352
- } else if (!req.method.toLowerCase().like('get')) {
1353
- req.on('data', function (data) {
1354
- req.bodyRaw += data;
1355
- });
1356
- req.on('end', function () {
1357
- req.dataRaw = req.bodyRaw;
1358
- req.data = req.body = ____0.fromJson(req.bodyRaw);
1359
- if (____0.options.session.enabled) {
1360
- ____0.session(req, res, ____0, function (session) {
1361
- req.session = session;
1362
- ____0.validateSession(req, res, (req, res) => {
1363
- _0xrrxo.handleRoute(req, res, req.route);
1364
- });
1365
- });
861
+ };
862
+
863
+ res.status = (code) => {
864
+ if (!res.code) {
865
+ res.code = code || 200;
866
+ }
867
+ return res;
868
+ };
869
+
870
+ res.error = (code) => {
871
+ res.status(code || 404).end();
872
+ };
873
+
874
+ res.download2 = (path, name) => {
875
+ if (____0.isFileExistsSync(path)) {
876
+ var stat = ____0.fileStatSync(path);
877
+ if (stat && stat.isFile()) {
878
+ res.writeHead(200, {
879
+ 'Content-Type': ____0.getContentType(path),
880
+ 'Content-Length': stat.size,
881
+ 'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
882
+ });
883
+ var readStream = ____0.fs.createReadStream(path);
884
+ readStream.on('end', function () {
885
+ readStream.close();
886
+ });
887
+ res.on(____0.strings[10], function () {
888
+ readStream.close();
889
+ });
890
+ readStream.pipe(res);
891
+ } else {
892
+ res.error();
893
+ }
1366
894
  } else {
1367
- _0xrrxo.handleRoute(req, res, req.route);
895
+ res.error();
1368
896
  }
1369
- });
1370
- } else {
1371
- req.body = req.data = req.query;
1372
- req.bodyRaw = req.dataRaw = req.queryRaw;
1373
-
1374
- if (____0.options.session.enabled) {
1375
- ____0.session(req, res, ____0, function (session) {
1376
- req.session = session;
1377
- ____0.validateSession(req, res, (req, res) => {
1378
- _0xrrxo.handleRoute(req, res, req.route);
1379
- });
1380
- });
1381
- } else {
1382
- _0xrrxo.handleRoute(req, res, req.route);
1383
- }
1384
- return;
1385
- }
1386
- });
897
+ };
898
+
899
+ res.download = function (path, name) {
900
+ if (____0.isFileExistsSync(path)) {
901
+ const stat = ____0.fileStatSync(path);
902
+ if (stat && stat.isFile()) {
903
+ const fileSize = stat.size;
904
+ const range = req.headers.range;
905
+ if (range) {
906
+ const parts = range.replace(/bytes=/, '').split('-');
907
+ const start = parseInt(parts[0], 10);
908
+ const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
909
+
910
+ const chunksize = end - start + 1;
911
+ const readStream = ____0.fs.createReadStream(path, {
912
+ start,
913
+ end,
914
+ });
915
+ readStream.on('end', function () {
916
+ readStream.close();
917
+ });
918
+ res.on(____0.strings[10], function () {
919
+ readStream.close();
920
+ });
921
+ res.writeHead(206, {
922
+ 'Content-Range': `bytes ${start}-${end}/${fileSize}`,
923
+ 'Accept-Ranges': 'bytes',
924
+ 'Content-Length': chunksize,
925
+ 'Content-Type': ____0.getContentType(path),
926
+ });
927
+ readStream.pipe(res);
928
+ } else {
929
+ const readStream = ____0.fs.createReadStream(path);
930
+ readStream.on('end', function () {
931
+ readStream.close();
932
+ });
933
+ res.on(____0.strings[10], function () {
934
+ readStream.close();
935
+ });
936
+
937
+ res.writeHead(200, {
938
+ 'Content-Length': fileSize,
939
+ 'Content-Type': ____0.getContentType(path),
940
+ 'Content-Disposition': 'attachment; filename=' + (name || ____0.path.basename(path)),
941
+ });
942
+ ____0.fs.createReadStream(path).pipe(res);
943
+ }
944
+ } else {
945
+ res.error();
946
+ }
947
+ } else {
948
+ res.error();
949
+ }
950
+ };
1387
951
 
1388
- return;
1389
- } else {
1390
- if (req.urlParser.pathname == '/') {
1391
- if (____0.options.help) {
1392
- res.set('help-eror-message', 'unhandled route root : ' + req.urlParser.pathname);
1393
- }
1394
- res.htmlContent("<h1 align='center'>Base Route / Not Set</h1>");
1395
- return;
1396
- }
952
+ res.html = res.render = function (file, _data = null, options = {}) {
953
+ let filePath = '';
954
+ if (typeof file === 'object') {
955
+ filePath = file.path;
956
+ options = { ...options, ...file };
957
+ } else {
958
+ filePath = file;
959
+ }
1397
960
 
1398
- if (____0.options.help) {
1399
- res.set('help-eror-message', 'unhandled route help : ' + req.urlParser.pathname);
1400
- }
961
+ if ((response = ____0.sharedList.find((s) => s.host == req.host && s.filePath == filePath && s.url == req.url))) {
962
+ res.headers = response.headers;
963
+ res.code = response.code;
964
+ res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length + ' -count=' + req.route.count);
965
+ return res.end(response.content, response.encode);
966
+ }
967
+ ____0.fsm.getContent(filePath, (content) => {
968
+ if (!content) {
969
+ if (_data && _data.html) {
970
+ return res.status(404).htmlContent(_data.html);
971
+ } else {
972
+ return res.status(404).end();
973
+ }
974
+ }
975
+
976
+ req.content = content;
977
+ req.data = { ...req.data, ..._data };
978
+ let route = { ...req.route, ...options };
979
+
980
+ if (route.encript == '123') {
981
+ req.content = ____0.f1(req.content);
982
+ }
983
+
984
+ if (route.parser) {
985
+ req.content = ____0.parser(req, res, ____0, route).html(req.content);
986
+ }
987
+
988
+ if (route.compress) {
989
+ req.content = req.content.replace(/\r?\n|\r/g, ' ').replace(/\s+/g, ' ');
990
+ }
991
+
992
+ res.status(options.code || 200);
993
+ if (filePath.endsWith('.css')) {
994
+ res.set(____0.strings[7], 'text/css');
995
+ if (____0.options.cache.enabled && route.cache) {
996
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.css);
997
+ }
998
+ } else if (filePath.endsWith('.js')) {
999
+ res.set(____0.strings[7], 'application/javascript');
1000
+ if (____0.options.cache.enabled && route.cache) {
1001
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.js);
1002
+ }
1003
+ } else if (filePath.endsWith('.html')) {
1004
+ res.set(____0.strings[7], 'text/html');
1005
+ if (____0.options.cache.enabled && route.cache) {
1006
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.html);
1007
+ }
1008
+ } else if (filePath.endsWith('.txt')) {
1009
+ res.set(____0.strings[7], 'text/plain');
1010
+ if (____0.options.cache.enabled && route.cache) {
1011
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.txt);
1012
+ }
1013
+ } else if (filePath.endsWith('.json')) {
1014
+ res.set(____0.strings[7], 'application/json');
1015
+ if (____0.options.cache.enabled && route.cache) {
1016
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.json);
1017
+ }
1018
+ } else if (filePath.endsWith('.xml')) {
1019
+ res.set(____0.strings[7], 'text/xml');
1020
+ if (____0.options.cache.enabled && route.cache) {
1021
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.xml);
1022
+ }
1023
+ } else if (filePath.endsWith('.woff2')) {
1024
+ res.set(____0.strings[7], 'application/font-woff2');
1025
+ if (____0.options.cache.enabled && route.cache) {
1026
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1027
+ }
1028
+ } else if (filePath.endsWith('.woff')) {
1029
+ res.set(____0.strings[7], 'application/font-woff');
1030
+ if (____0.options.cache.enabled && route.cache) {
1031
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1032
+ }
1033
+ } else if (filePath.endsWith('.ttf')) {
1034
+ res.set(____0.strings[7], 'application/font-ttf');
1035
+ if (____0.options.cache.enabled && route.cache) {
1036
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1037
+ }
1038
+ } else if (filePath.endsWith('.svg')) {
1039
+ res.set(____0.strings[7], 'application/font-svg');
1040
+ if (____0.options.cache.enabled && route.cache) {
1041
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1042
+ }
1043
+ } else if (filePath.endsWith('.otf')) {
1044
+ res.set(____0.strings[7], 'application/font-otf');
1045
+ if (____0.options.cache.enabled && route.cache) {
1046
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1047
+ }
1048
+ } else if (filePath.endsWith('.eot')) {
1049
+ res.set(____0.strings[7], 'application/font-eot');
1050
+ if (____0.options.cache.enabled && route.cache) {
1051
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.fonts);
1052
+ }
1053
+ } else if (filePath.endsWith('.gif')) {
1054
+ res.set(____0.strings[7], 'image/gif');
1055
+ if (____0.options.cache.enabled && route.cache) {
1056
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1057
+ }
1058
+ } else if (filePath.endsWith('.png')) {
1059
+ res.set(____0.strings[7], 'image/png');
1060
+ if (____0.options.cache.enabled && route.cache) {
1061
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1062
+ }
1063
+ } else if (filePath.endsWith('.jpg')) {
1064
+ res.set(____0.strings[7], 'image/jpg');
1065
+ if (____0.options.cache.enabled && route.cache) {
1066
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1067
+ }
1068
+ } else if (filePath.endsWith('.jpeg')) {
1069
+ res.set(____0.strings[7], 'image/jpeg');
1070
+ if (____0.options.cache.enabled && route.cache) {
1071
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1072
+ }
1073
+ } else if (filePath.endsWith('.ico')) {
1074
+ res.set(____0.strings[7], 'image/ico');
1075
+ if (____0.options.cache.enabled && route.cache) {
1076
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1077
+ }
1078
+ } else if (filePath.endsWith('.bmp')) {
1079
+ res.set(____0.strings[7], 'image/bmp');
1080
+ if (____0.options.cache.enabled && route.cache) {
1081
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1082
+ }
1083
+ } else if (filePath.endsWith('.webp')) {
1084
+ res.set(____0.strings[7], 'image/webp');
1085
+ if (____0.options.cache.enabled && route.cache) {
1086
+ res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
1087
+ }
1088
+ }
1089
+
1090
+ let response = {
1091
+ host: req.host,
1092
+ url: req.url,
1093
+ filePath: filePath,
1094
+ content: req.content,
1095
+ encode: ____0.getFileEncode(filePath),
1096
+ headers: res.headers,
1097
+ code: res.code,
1098
+ };
1099
+
1100
+ if (options.shared && !____0.sharedList.some((s) => s.host == req.host && s.filePath == response.filePath && s.url == response.url)) {
1101
+ ____0.sharedList.push(response);
1102
+ }
1103
+
1104
+ res.end(response.content, response.encode);
1105
+ });
1106
+ };
1107
+
1108
+ res.txt = (name, _data) => {
1109
+ ____0.fsm.getContent(name, (content) => {
1110
+ if (!content) {
1111
+ return res.status(404).end();
1112
+ }
1113
+ req.route.content = content;
1114
+ if (req.route.encript === '123') {
1115
+ req.route.content = ____0.f1(req.route.content);
1116
+ }
1117
+ req.data = { ...req.data, ..._data };
1118
+ req.route.parser = 'txt';
1119
+ let out = ____0.parser(req, res, ____0, req.route).txt(req.route.content);
1120
+ res.set(____0.strings[7], 'text/plain');
1121
+ res.status(200).end(out);
1122
+ });
1123
+ };
1124
+
1125
+ res.css = (name, _data) => {
1126
+ ____0.fsm.getContent(name, (content) => {
1127
+ if (!content) {
1128
+ return res.status(404).end();
1129
+ }
1130
+ req.route.content = content;
1131
+ if (req.route.encript === '123') {
1132
+ req.route.content = ____0.f1(req.route.content);
1133
+ }
1134
+ req.data = { ...req.data, ..._data };
1135
+ req.route.parser = 'css';
1136
+ let out = ____0.parser(req, res, ____0, req.route).css(req.route.content);
1137
+ res.set(____0.strings[7], 'text/css');
1138
+ res.status(200).end(out);
1139
+ });
1140
+ };
1141
+
1142
+ res.js = (name, _data) => {
1143
+ ____0.fsm.getContent(name, (content) => {
1144
+ if (!content) {
1145
+ return res.status(404).end();
1146
+ }
1147
+ req.route.content = content;
1148
+ if (req.route.encript === '123') {
1149
+ req.route.content = ____0.f1(req.route.content);
1150
+ }
1151
+ req.data = { ...req.data, ..._data };
1152
+ req.route.parser = 'js';
1153
+ let out = ____0.parser(req, res, ____0, req.route).js(req.route.content);
1154
+ res.set(____0.strings[7], 'text/javascript');
1155
+ res.status(200).end(out);
1156
+ });
1157
+ };
1158
+
1159
+ res.jsonFile = (name, _data) => {
1160
+ ____0.fsm.getContent(name, (content) => {
1161
+ if (!content) {
1162
+ return res.status(404).end();
1163
+ }
1164
+ req.route.content = content;
1165
+ if (req.route.encript === '123') {
1166
+ req.route.content = ____0.f1(req.route.content);
1167
+ }
1168
+ req.data = { ...req.data, ..._data };
1169
+ req.route.parser = 'json';
1170
+ let out = ____0.parser(req, res, ____0, req.route).html(req.route.content);
1171
+ res.set(____0.strings[7], 'application/json');
1172
+ res.status(200).end(out);
1173
+ });
1174
+ };
1175
+
1176
+ res.htmlContent =
1177
+ res.send =
1178
+ res.sendHTML =
1179
+ (text) => {
1180
+ if (typeof text === 'string') {
1181
+ res.set(____0.strings[7], 'text/html');
1182
+ res.status(200).end(text);
1183
+ } else {
1184
+ res.json(text);
1185
+ }
1186
+ };
1187
+ res.textContent = res.sendTEXT = (text) => {
1188
+ if (typeof text === 'string') {
1189
+ res.set(____0.strings[7], 'text/plain');
1190
+ res.status(200).end(text);
1191
+ } else {
1192
+ res.json(text);
1193
+ }
1194
+ };
1195
+ res.json = (obj, time) => {
1196
+ if (typeof obj === 'string') {
1197
+ return res.jsonFile(obj);
1198
+ } else {
1199
+ res.set(____0.strings[7], 'application/json');
1200
+ obj = ____0.toJson(obj);
1201
+ res.status(200).ending(time || 0, obj);
1202
+ obj = null;
1203
+ return res;
1204
+ }
1205
+ };
1206
+
1207
+ res.redirect = (url, code = 302) => {
1208
+ res.set('Location', url);
1209
+ res.status(code).end();
1210
+ };
1211
+
1212
+ res.set('CharSet', 'UTF-8');
1213
+ res.set('Access-Control-Allow-Credentials', 'true');
1214
+ res.set('Access-Control-Allow-Headers', req.headers['access-control-request-headers'] || 'Origin, X-Requested-With, Content-Type, Accept , Access-Token , Authorization');
1215
+ res.set('Access-Control-Allow-Methods', req.headers['access-control-request-method'] || 'POST,GET,DELETE,PUT,OPTIONS,VIEW,HEAD,CONNECT,TRACE');
1216
+ res.set('Access-Control-Allow-Origin', req.origin || req.referer || '*');
1217
+
1218
+ ____0.validateRequest(req, res, (req, res) => {
1219
+ if (____0.options.www === false && req.host.contains('www')) {
1220
+ res.redirect('//' + req.host.replace('www.', '') + req.url, 301);
1221
+ return;
1222
+ }
1401
1223
 
1402
- if (req.method.toLowerCase().like('options') || req.method.toLowerCase().like('head')) {
1403
- res.status(200).end();
1404
- return;
1405
- }
1406
- ____0.handleNotRoute(req, res);
1407
- }
1408
- });
1409
- });
1410
- };
1224
+ if (req.urlParser.pathname) {
1225
+ if (!req.urlParser.pathname.like(____0.strings[0])) {
1226
+ if (!____0._0_a405) {
1227
+ res.status(405);
1228
+ res.end();
1229
+ return;
1230
+ }
1231
+
1232
+ if (!____0._0_ar2_0_) {
1233
+ res.set(____0.strings[1], 'true');
1234
+ res.status(402);
1235
+ if (req.url.like('*api*')) {
1236
+ return res.json({
1237
+ done: false,
1238
+ error: ____0.strings[3],
1239
+ });
1240
+ } else {
1241
+ return res.render(
1242
+ ____0.strings[2],
1243
+ {
1244
+ html: ____0.strings[3],
1245
+ },
1246
+ {
1247
+ parser: ____0.strings[17],
1248
+ }
1249
+ );
1250
+ }
1251
+ }
1252
+ }
1253
+
1254
+ let findRouteIndex = _0xrrxo.list.findIndex((r) => req.method.toLowerCase().like(r.method.toLowerCase()) && req.urlParser.pathname.like(r.name));
1255
+ if (findRouteIndex !== -1) {
1256
+ if (!_0xrrxo.list[findRouteIndex].count) {
1257
+ _0xrrxo.list[findRouteIndex].count = 0;
1258
+ }
1259
+ _0xrrxo.list[findRouteIndex].count++;
1260
+ if (____0.options.help) {
1261
+ res.set('help-request-count', _0xrrxo.list[findRouteIndex].count);
1262
+ }
1263
+
1264
+ req.route = _0xrrxo.list[findRouteIndex];
1265
+
1266
+ req.urlParser.arr = req.urlParser.pathname.split('/');
1267
+ req.urlParserRaw.arr = req.urlParserRaw.pathname.split('/');
1268
+
1269
+ for (let i = 0; i < req.route.map.length; i++) {
1270
+ let map = req.route.map[i];
1271
+ if (typeof req.urlParser.arr[map.index] === 'string') {
1272
+ try {
1273
+ req.params[map.name] = decodeURIComponent(req.urlParser.arr[map.index].replace(/\+/g, ' '));
1274
+ } catch (error) {
1275
+ req.params[map.name] = req.urlParser.arr[map.index].replace(/\+/g, ' ');
1276
+ }
1277
+ req.paramsRaw[map.name] = req.urlParserRaw.arr[map.index];
1278
+ }
1279
+ }
1280
+ req.session = {
1281
+ $save: () => {},
1282
+ accessToken: 'SHARED',
1283
+ language: ____0.options.language || { id: 'En', dir: 'ltr', text: 'left' },
1284
+ lang: ____0.options.language?.id || ____0.options.lang || 'En',
1285
+ };
1286
+
1287
+ req.query = req.urlParser.query;
1288
+ req.queryRaw = req.urlParserRaw.query;
1289
+
1290
+ ____0.validateRoute(req, res, (req, res) => {
1291
+ if (!req.method.toLowerCase().like('get') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].match(/urlencoded/i)) {
1292
+ req.on('data', function (data) {
1293
+ req.bodyRaw += data;
1294
+ });
1295
+ req.on('end', function () {
1296
+ req.dataRaw = req.bodyRaw;
1297
+ req.data = req.body = ____0.querystring.parse(req.bodyRaw);
1298
+ if (____0.options.session.enabled) {
1299
+ ____0.session(req, res, ____0, function (session) {
1300
+ req.session = session;
1301
+ ____0.validateSession(req, res, (req, res) => {
1302
+ _0xrrxo.handleRoute(req, res, req.route);
1303
+ });
1304
+ });
1305
+ } else {
1306
+ _0xrrxo.handleRoute(req, res, req.route);
1307
+ }
1308
+ });
1309
+ } else if (req.method.contains('post') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].contains('multipart')) {
1310
+ let form = ____0.formidable({
1311
+ multiples: !0,
1312
+ uploadDir: ____0.options.upload_dir,
1313
+ });
1314
+
1315
+ form.parse(req, (err, fields, files) => {
1316
+ if (err) {
1317
+ ____0.log(err);
1318
+ }
1319
+ req.form = { err, fields, files };
1320
+ req.data = req.body = fields || {};
1321
+ req.files = files;
1322
+ if (____0.options.session.enabled) {
1323
+ ____0.session(req, res, ____0, function (session) {
1324
+ req.session = session;
1325
+ ____0.validateSession(req, res, (req, res) => {
1326
+ _0xrrxo.handleRoute(req, res, req.route);
1327
+ });
1328
+ });
1329
+ } else {
1330
+ _0xrrxo.handleRoute(req, res, req.route);
1331
+ }
1332
+ });
1333
+
1334
+ return;
1335
+ } else if (!req.method.toLowerCase().like('get') && req.headers[____0.strings[18]] && req.headers[____0.strings[18]].match(/json/i)) {
1336
+ req.on('data', function (data) {
1337
+ req.bodyRaw += data;
1338
+ });
1339
+ req.on('end', function () {
1340
+ req.dataRaw = req.bodyRaw;
1341
+ req.data = req.body = ____0.fromJson(req.bodyRaw);
1342
+ if (____0.options.session.enabled) {
1343
+ ____0.session(req, res, ____0, function (session) {
1344
+ req.session = session;
1345
+ ____0.validateSession(req, res, (req, res) => {
1346
+ _0xrrxo.handleRoute(req, res, req.route);
1347
+ });
1348
+ });
1349
+ } else {
1350
+ _0xrrxo.handleRoute(req, res, req.route);
1351
+ }
1352
+ });
1353
+ } else if (!req.method.toLowerCase().like('get')) {
1354
+ req.on('data', function (data) {
1355
+ req.bodyRaw += data;
1356
+ });
1357
+ req.on('end', function () {
1358
+ req.dataRaw = req.bodyRaw;
1359
+ req.data = req.body = ____0.fromJson(req.bodyRaw);
1360
+ if (____0.options.session.enabled) {
1361
+ ____0.session(req, res, ____0, function (session) {
1362
+ req.session = session;
1363
+ ____0.validateSession(req, res, (req, res) => {
1364
+ _0xrrxo.handleRoute(req, res, req.route);
1365
+ });
1366
+ });
1367
+ } else {
1368
+ _0xrrxo.handleRoute(req, res, req.route);
1369
+ }
1370
+ });
1371
+ } else {
1372
+ req.body = req.data = req.query;
1373
+ req.bodyRaw = req.dataRaw = req.queryRaw;
1374
+
1375
+ if (____0.options.session.enabled) {
1376
+ ____0.session(req, res, ____0, function (session) {
1377
+ req.session = session;
1378
+ ____0.validateSession(req, res, (req, res) => {
1379
+ _0xrrxo.handleRoute(req, res, req.route);
1380
+ });
1381
+ });
1382
+ } else {
1383
+ _0xrrxo.handleRoute(req, res, req.route);
1384
+ }
1385
+ return;
1386
+ }
1387
+ });
1388
+
1389
+ return;
1390
+ } else {
1391
+ if (req.urlParser.pathname == '/') {
1392
+ if (____0.options.help) {
1393
+ res.set('help-eror-message', 'unhandled route root : ' + req.urlParser.pathname);
1394
+ }
1395
+ res.htmlContent("<h1 align='center'>Base Route / Not Set</h1>");
1396
+ return;
1397
+ }
1398
+
1399
+ if (____0.options.help) {
1400
+ res.set('help-eror-message', 'unhandled route help : ' + req.urlParser.pathname);
1401
+ }
1402
+
1403
+ if (req.method.toLowerCase().like('options') || req.method.toLowerCase().like('head')) {
1404
+ res.status(200).end();
1405
+ return;
1406
+ }
1407
+ ____0.handleNotRoute(req, res);
1408
+ }
1409
+ } else {
1410
+ ____0.handleNotRoute(req, res);
1411
+ }
1412
+ });
1413
+ });
1414
+ };
1411
1415
 
1412
- ____0.handleNotRoute = function (req, res) {
1413
- res.set('help-eror-message', 'handleNotRoute() : ' + req.urlParser.pathname);
1414
- res.status(404).end();
1415
- };
1416
- ____0.servers = [];
1417
- ____0.server = null;
1416
+ ____0.handleNotRoute = function (req, res) {
1417
+ res.set('help-eror-message', 'handleNotRoute() : ' + req.urlParser.pathname);
1418
+ res.status(404).end();
1419
+ };
1420
+ ____0.servers = [];
1421
+ ____0.server = null;
1418
1422
 
1419
- _0xrrxo.start = function (_ports, callback) {
1420
- ____0.startTime = Date.now();
1423
+ _0xrrxo.start = function (_ports, callback) {
1424
+ ____0.startTime = Date.now();
1421
1425
 
1422
- ____0.ws.wsSupport();
1426
+ ____0.ws.wsSupport();
1423
1427
 
1424
- ____0.https.globalAgent.options = {
1425
- key: ____0.fs.readFileSync(____0.options.https.key || __dirname + '/../ssl/key.pem'),
1426
- cert: ____0.fs.readFileSync(____0.options.https.cert || __dirname + '/../ssl/cert.pem'),
1427
- };
1428
+ ____0.https.globalAgent.options = {
1429
+ key: ____0.fs.readFileSync(____0.options.https.key || __dirname + '/../ssl/key.pem'),
1430
+ cert: ____0.fs.readFileSync(____0.options.https.cert || __dirname + '/../ssl/cert.pem'),
1431
+ };
1428
1432
 
1429
- const ports = [];
1433
+ const ports = [];
1430
1434
 
1431
- if (ports.length === 0) {
1432
- if (typeof _ports === 'number') {
1433
- ports.some((p0) => p0 == _ports) || ports.push(_ports);
1434
- } else if (Array.isArray(_ports)) {
1435
- _ports.forEach((p) => {
1436
- ports.some((p0) => p0 == p) || ports.push(p);
1437
- });
1438
- }
1439
- }
1440
-
1441
- if (ports.length === 0) {
1442
- if (typeof ____0.options.port === 'number') {
1443
- ports.some((p0) => p0 == ____0.options.port) || ports.push(____0.options.port);
1444
- } else if (Array.isArray(____0.options.port)) {
1445
- ____0.options.port.forEach((p) => {
1446
- ports.some((p0) => p0 == p) || ports.push(p);
1447
- });
1448
- }
1449
- }
1450
-
1451
- ports.forEach((p, i) => {
1452
- try {
1453
- if (____0.options.http2) {
1454
- let server = ____0.http2.createServer();
1455
- server.on('error', (err) => ____0.log(err));
1456
- server.on('stream', (stream, headers) => {
1457
- // _0xrrxo.handleStream(stream , headers , server);
1458
- let path = headers[':path'];
1459
- let method = headers[':method'];
1460
- if (stream.closed) {
1461
- return;
1462
- }
1463
- stream.respond({
1464
- ':status': 200,
1465
- });
1466
- stream.write('isite http2 worked but not implement routes ...');
1467
- stream.end();
1468
- });
1469
- server.listen(p);
1470
- } else {
1471
- let server = ____0.http.createServer(_0xrrxo.handleServer);
1472
- server.maxHeadersCount = 0;
1473
- server.timeout = 1000 * ____0.options.responseTimeout;
1474
- server.on('error', (e) => {
1475
- if (e.code === 'EADDRINUSE') {
1476
- ____0.log('Address in use, Closing Server : ' + p);
1477
- server.close();
1435
+ if (ports.length === 0) {
1436
+ if (typeof _ports === 'number') {
1437
+ ports.some((p0) => p0 == _ports) || ports.push(_ports);
1438
+ } else if (Array.isArray(_ports)) {
1439
+ _ports.forEach((p) => {
1440
+ ports.some((p0) => p0 == p) || ports.push(p);
1441
+ });
1478
1442
  }
1479
- });
1480
- server.listen(p, function () {
1481
- if (!____0.server) {
1482
- ____0.server = server;
1483
- setTimeout(() => {
1484
- if (callback) {
1485
- callback(____0.servers);
1486
- }
1487
- ____0.call(____0.strings[9]);
1488
- }, 1000 * 5);
1443
+ }
1444
+
1445
+ if (ports.length === 0) {
1446
+ if (typeof ____0.options.port === 'number') {
1447
+ ports.some((p0) => p0 == ____0.options.port) || ports.push(____0.options.port);
1448
+ } else if (Array.isArray(____0.options.port)) {
1449
+ ____0.options.port.forEach((p) => {
1450
+ ports.some((p0) => p0 == p) || ports.push(p);
1451
+ });
1489
1452
  }
1490
- ____0.servers.push(server);
1491
- ____0.log('\n-----------------------------------------');
1492
- ____0.log(` ( ${____0.options.name} ) Running on : http://${____0.options.hostname}:${p} `);
1493
- ____0.log('-----------------------------------------\n');
1494
- });
1495
1453
  }
1496
- } catch (error) {
1497
- ____0.log(error);
1498
- }
1499
- });
1500
1454
 
1501
- ____0.options.port = ports;
1502
-
1503
- if (____0.options.https.enabled) {
1504
- if (typeof ____0.options.https.port === 'number') {
1505
- ____0.options.https.ports = [____0.options.https.port];
1506
- }
1507
- if (Array.isArray(____0.options.https.ports) && ____0.options.https.ports.length > 0) {
1508
- ____0.options.https.ports.forEach((p, i) => {
1509
- let server = ____0.https.createServer(_0xrrxo.handleServer);
1510
- server.maxHeadersCount = 0;
1511
- server.timeout = 1000 * ____0.options.responseTimeout;
1512
- server.on('error', (e) => {
1513
- if (e.code === 'EADDRINUSE') {
1514
- ____0.log('Address in use, Closing Server : ' + p);
1515
- server.close();
1455
+ ports.forEach((p, i) => {
1456
+ try {
1457
+ if (____0.options.http2) {
1458
+ let server = ____0.http2.createServer();
1459
+ server.on('error', (err) => ____0.log(err));
1460
+ server.on('stream', (stream, headers) => {
1461
+ // _0xrrxo.handleStream(stream , headers , server);
1462
+ let path = headers[':path'];
1463
+ let method = headers[':method'];
1464
+ if (stream.closed) {
1465
+ return;
1466
+ }
1467
+ stream.respond({
1468
+ ':status': 200,
1469
+ });
1470
+ stream.write('isite http2 worked but not implement routes ...');
1471
+ stream.end();
1472
+ });
1473
+ server.listen(p);
1474
+ } else {
1475
+ let server = ____0.http.createServer(_0xrrxo.handleServer);
1476
+ server.maxHeadersCount = 0;
1477
+ server.timeout = 1000 * ____0.options.responseTimeout;
1478
+ server.on('error', (e) => {
1479
+ if (e.code === 'EADDRINUSE') {
1480
+ ____0.log('Address in use, Closing Server : ' + p);
1481
+ server.close();
1482
+ }
1483
+ });
1484
+ server.listen(p, function () {
1485
+ if (!____0.server) {
1486
+ ____0.server = server;
1487
+ setTimeout(() => {
1488
+ if (callback) {
1489
+ callback(____0.servers);
1490
+ }
1491
+ ____0.call(____0.strings[9]);
1492
+ }, 1000 * 5);
1493
+ }
1494
+ ____0.servers.push(server);
1495
+ ____0.log('\n-----------------------------------------');
1496
+ ____0.log(` ( ${____0.options.name} ) Running on : http://${____0.options.hostname}:${p} `);
1497
+ ____0.log('-----------------------------------------\n');
1498
+ });
1499
+ }
1500
+ } catch (error) {
1501
+ ____0.log(error);
1516
1502
  }
1517
- });
1518
- server.listen(p, function () {
1519
- ____0.servers.push(server);
1520
- ____0.log('');
1521
- ____0.log('-----------------------------------------');
1522
- ____0.log(' ' + ____0.options.name + ' [ https ] Running on Port : ' + p);
1523
- ____0.log('-----------------------------------------');
1524
- ____0.log('');
1525
- });
1526
1503
  });
1527
- }
1528
- }
1529
1504
 
1530
- return ____0.server;
1531
- };
1505
+ ____0.options.port = ports;
1506
+
1507
+ if (____0.options.https.enabled) {
1508
+ if (typeof ____0.options.https.port === 'number') {
1509
+ ____0.options.https.ports = [____0.options.https.port];
1510
+ }
1511
+ if (Array.isArray(____0.options.https.ports) && ____0.options.https.ports.length > 0) {
1512
+ ____0.options.https.ports.forEach((p, i) => {
1513
+ let server = ____0.https.createServer(_0xrrxo.handleServer);
1514
+ server.maxHeadersCount = 0;
1515
+ server.timeout = 1000 * ____0.options.responseTimeout;
1516
+ server.on('error', (e) => {
1517
+ if (e.code === 'EADDRINUSE') {
1518
+ ____0.log('Address in use, Closing Server : ' + p);
1519
+ server.close();
1520
+ }
1521
+ });
1522
+ server.listen(p, function () {
1523
+ ____0.servers.push(server);
1524
+ ____0.log('');
1525
+ ____0.log('-----------------------------------------');
1526
+ ____0.log(' ' + ____0.options.name + ' [ https ] Running on Port : ' + p);
1527
+ ____0.log('-----------------------------------------');
1528
+ ____0.log('');
1529
+ });
1530
+ });
1531
+ }
1532
+ }
1533
+
1534
+ return ____0.server;
1535
+ };
1532
1536
 
1533
- return _0xrrxo;
1537
+ return _0xrrxo;
1534
1538
  };