isite 2023.1.10 → 2023.8.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/parser.js CHANGED
@@ -692,6 +692,9 @@ module.exports = function init(req, res, ____0, route) {
692
692
  if (v.startsWith('##var.')) {
693
693
  v = v.replace('##var.', '').replace('##', '');
694
694
  txt = txt.replace(matches[i], renderVar(v));
695
+ } else if (v.startsWith('##word.')) {
696
+ v = v.replace('##word.', '').replace('##', '');
697
+ txt = txt.replace(matches[i], renderWord(v));
695
698
  } else if (v.startsWith('##user.')) {
696
699
  v = v.replace('##user.', '').replace('##', '');
697
700
  txt = txt.replace(matches[i], renderUser(v));
@@ -707,9 +710,6 @@ module.exports = function init(req, res, ____0, route) {
707
710
  } else if (v.startsWith('##json.')) {
708
711
  v = v.replace('##json.', '').replace('##', '');
709
712
  txt = txt.replace(matches[i], renderJson(v));
710
- } else if (v.startsWith('##word.')) {
711
- v = v.replace('##word.', '').replace('##', '');
712
- txt = txt.replace(matches[i], renderWord(v));
713
713
  } else if (v.startsWith('##setting.')) {
714
714
  v = v.replace('##setting.', '').replace('##', '');
715
715
  txt = txt.replace(matches[i], renderSetting(v));
package/lib/routing.js CHANGED
@@ -153,6 +153,11 @@ module.exports = function init(____0) {
153
153
  res.set(____0.strings[7], 'image/bmp');
154
154
  if (____0.options.cache.enabled) res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
155
155
 
156
+ res.end(req.content, encode);
157
+ } else if (route.path.endsWith('.webp')) {
158
+ res.set(____0.strings[7], 'image/webp');
159
+ if (____0.options.cache.enabled) res.set('Cache-Control', 'public, max-age=' + 60 * ____0.options.cache.images);
160
+
156
161
  res.end(req.content, encode);
157
162
  } else if (route.path.endsWith('.svg')) {
158
163
  res.set(____0.strings[7], 'image/svg+xml');
@@ -325,9 +330,9 @@ module.exports = function init(____0) {
325
330
  }
326
331
  if (r && r.name && Array.isArray(r.name)) {
327
332
  r.name.forEach((r2) => {
328
- let r3 = Object.assign({}, r);
333
+ let r3 = { ...r };
329
334
  r3.name = r2;
330
- _0xrrxo.onGET(r3, r.callback);
335
+ _0xrrxo.onREQUEST(r3, r.callback);
331
336
  });
332
337
  return;
333
338
  }
@@ -369,6 +374,7 @@ module.exports = function init(____0) {
369
374
  route.parser = r.parser || 'static';
370
375
  route.parserDir = r.parserDir || ____0.dir;
371
376
  route.masterPage = r.masterPage || null;
377
+ route.overwrite = r.overwrite ?? !1;
372
378
  route.cache = r.cache ?? !0;
373
379
  route.hide = r.hide ?? !1;
374
380
  route.encript = r.encript;
@@ -448,21 +454,18 @@ module.exports = function init(____0) {
448
454
  route.name = '/' + route.name;
449
455
  }
450
456
 
451
- let exist = !1;
452
- _0xrrxo.list.forEach((rr) => {
453
- if (rr.name == route.name && rr.method == route.method) {
454
- exist = !0;
455
- }
456
- });
457
-
458
- if (!exist) {
457
+ route.name = encodeURI(route.name);
458
+ let index = _0xrrxo.list.findIndex((rr) => rr.name == route.name && rr.method == route.method);
459
+ if (index === -1) {
459
460
  _0xrrxo.list.push(route);
460
- } else {
461
+ } else if (index > -1 && !route.overwrite) {
461
462
  if (route.name.like('*api/*')) {
462
463
  ____0.log('[ Duplicate API ] ' + route.name);
463
464
  } else {
464
- ____0.log('[ Duplicate Route ] ' + route.name + ' || ' + route.path);
465
+ ____0.log('[ Duplicate Route ] ' + route.name);
465
466
  }
467
+ } else {
468
+ _0xrrxo.list[index] = route;
466
469
  }
467
470
  }
468
471
  } catch (err) {
@@ -676,9 +679,17 @@ module.exports = function init(____0) {
676
679
 
677
680
  return userFinger;
678
681
  };
679
- req.word = function(name){
680
- return ____0.word(name)[req.session.lang] || name;
681
- }
682
+ req.word = function (name) {
683
+ let w = ____0.word(name);
684
+ if (!w.hostList) {
685
+ return w[req.session.lang] || name;
686
+ } else {
687
+ if ((w2 = w.hostList.find((h) => req.host.like(h.name)))) {
688
+ return w2[req.session.lang] || name;
689
+ }
690
+ }
691
+ return w[req.session.lang] || name;
692
+ };
682
693
 
683
694
  res.code = null;
684
695
  req.socket.remoteAddress = req.socket.remoteAddress || '';
@@ -731,8 +742,12 @@ module.exports = function init(____0) {
731
742
  res.end = function (arg1, arg2, arg3, arg4) {
732
743
  if (typeof arg1 === 'number') {
733
744
  res.writeHead(arg1);
734
- return res.end0();
745
+ return res.end(arg2, arg3, arg4);
735
746
  } else {
747
+ if (res.headers === undefined || res.headers[____0.strings[7]] === undefined) {
748
+ res.set(____0.strings[7], 'text/plain');
749
+ }
750
+
736
751
  if (
737
752
  arg1 &&
738
753
  res.headers &&
@@ -743,23 +758,19 @@ module.exports = function init(____0) {
743
758
  res.headers[____0.strings[7]].like('*text/plain*') ||
744
759
  res.headers[____0.strings[7]].like('*application/json*'))
745
760
  ) {
746
- if (req.acceptEncoding.match(/\bdeflate\b/) && typeof arg1 === 'string') {
747
- res.set(____0.strings[8], 'deflate');
748
- res.set('Vary', ____0.strings[5]);
749
- arg1 = ____0.zlib.deflateSync(Buffer.from(arg1));
750
- } else if (req.acceptEncoding.match(/\bgzip\b/) && typeof arg1 === 'string') {
761
+ if (req.acceptEncoding.like('*gzip*') && typeof arg1 === 'string') {
751
762
  res.set(____0.strings[8], 'gzip');
752
763
  res.set('Vary', ____0.strings[5]);
753
764
  arg1 = ____0.zlib.gzipSync(Buffer.from(arg1));
765
+ } else if (req.acceptEncoding.like('*deflate*') && typeof arg1 === 'string') {
766
+ res.set(____0.strings[8], 'deflate');
767
+ res.set('Vary', ____0.strings[5]);
768
+ arg1 = ____0.zlib.deflateSync(Buffer.from(arg1));
754
769
  } else {
755
770
  // ____0.log(typeof arg1)
756
771
  }
757
772
  }
758
773
 
759
- if (res.headers === undefined || res.headers[____0.strings[7]] === undefined) {
760
- res.set(____0.strings[7], 'text/plain');
761
- }
762
-
763
774
  res.writeHead(res.code || res.statusCode || 200);
764
775
  arg1 = arg1 || ' ';
765
776
  return res.end0(arg1, arg2, arg3, arg4);
package/lib/words.js CHANGED
@@ -1,18 +1,14 @@
1
1
  module.exports = function init(____0) {
2
2
  let app = function () {};
3
3
  app.list = [];
4
- app.$collectoin = ____0.connectCollection('app_words');
5
- app.ready = false;
4
+ app.userWordsPath = process.cwd() + '/.words.json';
6
5
 
7
- app.$collectoin.findAll({ limit: 10000 }, (err, docs) => {
8
- if (!err && docs && docs.length > 0) {
9
- docs.forEach((doc) => {
10
- doc.$isDB = true;
11
- app.list.unshift(doc);
12
- });
6
+ if (____0.isFileExistsSync(app.userWordsPath)) {
7
+ let words2 = JSON.parse(____0.readFileSync(app.userWordsPath));
8
+ if (words2 && Array.isArray(words2)) {
9
+ app.list = words2;
13
10
  }
14
- app.ready = true;
15
- });
11
+ }
16
12
 
17
13
  app.word = function (obj) {
18
14
  if (typeof obj === 'string') {
@@ -27,33 +23,26 @@ module.exports = function init(____0) {
27
23
  if ((w = app.list.find((w2) => w2.name === name))) {
28
24
  return w;
29
25
  } else {
30
- if (!app.ready) {
31
- return { name: name };
32
- }
33
26
  return app.add({ name: name });
34
27
  }
35
28
  };
36
29
 
37
- app.add = app.set = function (word) {
30
+ app.add = function (word) {
31
+ let index = app.list.findIndex((w) => w.name === word.name);
32
+ if (index === -1) {
33
+ app.list.push(word);
34
+ }
35
+ return word;
36
+ };
37
+ app.set = function (word) {
38
38
  let index = app.list.findIndex((w) => w.name === word.name);
39
39
  if (index === -1) {
40
40
  app.list.push(word);
41
- app.$collectoin.add(word, (err, doc) => {
42
- if (!err && doc) {
43
- let index = app.list.findIndex((w) => w.name === doc.name);
44
- app.list[index] = doc;
45
- }
46
- });
47
41
  } else {
48
- if (!app.list[index].$isDB || word.$isDB) {
49
- app.list[index] = word;
50
- app.$collectoin.update(app.list[index]);
51
- }
42
+ app.list[index] = word;
52
43
  }
53
-
54
44
  return word;
55
45
  };
56
-
57
46
  app.addList = function (list) {
58
47
  if (Array.isArray(list)) {
59
48
  list.forEach((doc) => {
@@ -66,20 +55,24 @@ module.exports = function init(____0) {
66
55
  ____0.readFile(path, (err, data) => {
67
56
  if (!err) {
68
57
  let arr = ____0.fromJson(data);
69
- arr.forEach((doc) => {
70
- app.add(doc);
71
- });
58
+ if (Array.isArray(arr)) {
59
+ arr.forEach((doc) => {
60
+ app.add(doc);
61
+ });
62
+ }
72
63
  }
73
64
  });
74
65
  };
75
66
 
76
67
  ____0.on(____0.strings[9], () => {
77
- ____0.get({ name: '/x-api/words', require: { permissions: ['login'] } }, (req, res) => {
68
+ ____0.get({ name: '/x-api/words' }, (req, res) => {
78
69
  res.json({ done: !0, words: app.list });
79
70
  });
80
71
 
81
- ____0.post({ name: '/x-api/words', require: { permissions: ['login'] } }, (req, res) => {
82
- res.json(app.add(req.data.word));
72
+ ____0.post({ name: '/x-api/words/save' }, (req, res) => {
73
+ app.list = req.data;
74
+ ____0.writeFileSync(app.userWordsPath, JSON.stringify(app.list));
75
+ res.json({ done: !0, count: app.list.length });
83
76
  });
84
77
 
85
78
  ____0.get('/x-api/words/get/:name', (req, res) => {
@@ -104,13 +104,13 @@ function setOptions(_options, ____0) {
104
104
  cache: {
105
105
  enabled: !0,
106
106
  html: 0,
107
- txt: 60 * 24 * 30,
108
- js: 60 * 24 * 30,
109
- css: 60 * 24 * 30,
110
- fonts: 60 * 24 * 30,
111
- images: 60 * 24 * 30,
112
- json: 60 * 24 * 30,
113
- xml: 60 * 24 * 30,
107
+ txt: 60 * 24 * 30 * 12,
108
+ js: 60 * 24 * 30 * 12,
109
+ css: 60 * 24 * 30 * 12,
110
+ fonts: 60 * 24 * 30 * 12,
111
+ images: 60 * 24 * 30 * 12,
112
+ json: 60 * 24 * 30 * 12,
113
+ xml: 60 * 24 * 30 * 12,
114
114
  },
115
115
  proto: {
116
116
  object: !1,
@@ -134,7 +134,6 @@ function setOptions(_options, ____0) {
134
134
  } else {
135
135
  userOptions = {};
136
136
  }
137
- console.log('User Template From .options.json', userOptions);
138
137
  }
139
138
  } catch (error) {
140
139
  console.error(error);
@@ -223,36 +223,6 @@ exports = module.exports = function init(____0) {
223
223
  }
224
224
  let ext = ____0.path.extname(path).replace('.', '');
225
225
  return ____0.mimeTypes[ext] || 'application/' + ext;
226
-
227
- if (path.endsWith('.exe')) {
228
- return 'application/octet-stream';
229
- } else if (path.endsWith('.txt')) {
230
- return 'text/plain';
231
- } else if (path.endsWith('.html')) {
232
- return 'text/html';
233
- } else if (path.endsWith('.pdf')) {
234
- return 'application/pdf';
235
- } else if (path.endsWith('.png')) {
236
- return 'image/png';
237
- } else if (path.endsWith('.jpg')) {
238
- return 'image/jpg';
239
- } else if (path.endsWith('.jpeg')) {
240
- return 'image/jpeg';
241
- } else if (path.endsWith('.jpeg')) {
242
- return 'image/jpeg';
243
- } else if (path.endsWith('.webp')) {
244
- return 'image/webp';
245
- } else if (path.endsWith('.ico')) {
246
- return 'image/ico';
247
- } else if (path.endsWith('.json')) {
248
- return 'application/json';
249
- } else if (path.endsWith('.apk')) {
250
- return 'application/vnd.android.package-archive';
251
- } else if (path.endsWith('.jar')) {
252
- return 'application/java-archive';
253
- } else {
254
- return 'application/' + ____0.path.extname(path);
255
- }
256
226
  };
257
227
 
258
228
  fn.getFileEncode = function (path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2023.01.10",
3
+ "version": "2023.08.11",
4
4
  "description": "Create Secure Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -47,6 +47,7 @@
47
47
  "nodemailer": "^6.7.8",
48
48
  "pdf-lib": "^1.17.1",
49
49
  "utf8": "^3.0.0",
50
+ "webp-converter": "^2.3.3",
50
51
  "ws": "^8.9.0",
51
52
  "xlsx": "^0.17.5"
52
53
  }