total5 0.0.16 → 0.0.17-1
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/changelog.txt +12 -0
- package/controller.js +2 -3
- package/http.js +1 -1
- package/index.js +2 -2
- package/mail.js +73 -15
- package/package.json +1 -1
- package/routing.js +7 -7
package/changelog.txt
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
========================
|
|
2
|
+
0.0.17
|
|
3
|
+
========================
|
|
4
|
+
|
|
5
|
+
- fixed error handling in emails
|
|
6
|
+
- improved returing `origin` in the CORS
|
|
7
|
+
- fixed removing routes via `route.remove()` method
|
|
8
|
+
- fixed `beautify` and `replacer` arguments in the `controller.json()`
|
|
9
|
+
- fixed `mail` priority
|
|
10
|
+
- fixed `kB` and `GB` units in the routing as upload limits
|
|
11
|
+
- `DEBUG` is set according to the `process.env.NODE_ENV` variable
|
|
12
|
+
|
|
1
13
|
========================
|
|
2
14
|
0.0.16
|
|
3
15
|
========================
|
package/controller.js
CHANGED
|
@@ -49,7 +49,6 @@ function Controller(req, res) {
|
|
|
49
49
|
ctrl.split2.push(path.toLowerCase());
|
|
50
50
|
|
|
51
51
|
ctrl.params = {};
|
|
52
|
-
ctrl.query = ctrl.uri.search.parseEncoded();
|
|
53
52
|
ctrl.files = [];
|
|
54
53
|
ctrl.body = {};
|
|
55
54
|
|
|
@@ -173,7 +172,7 @@ Controller.prototype = {
|
|
|
173
172
|
},
|
|
174
173
|
|
|
175
174
|
get address() {
|
|
176
|
-
return
|
|
175
|
+
return this.protocol + '://' + (this.headers?.host || '') + (this.req?.url || '');
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
};
|
|
@@ -300,7 +299,7 @@ Controller.prototype.json = function(value, beautify, replacer) {
|
|
|
300
299
|
response.headers['cache-control'] = NOCACHE;
|
|
301
300
|
response.headers.vary = 'Accept-Encoding, Last-Modified, User-Agent';
|
|
302
301
|
response.headers.expires = '-1';
|
|
303
|
-
response.value = JSON.stringify(value, beautify ? '\t' : null
|
|
302
|
+
response.value = JSON.stringify(value, replacer, beautify ? '\t' : null);
|
|
304
303
|
ctrl.flush();
|
|
305
304
|
F.stats.response.json++;
|
|
306
305
|
};
|
package/http.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.listen = function(req, res) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (F.config.$blacklist && F.config.$blacklist.
|
|
30
|
+
if (F.config.$blacklist && F.config.$blacklist.includes(ctrl.ip)) {
|
|
31
31
|
F.stats.request.blocked++;
|
|
32
32
|
ctrl.fallback(400, 'IP address is blocked');
|
|
33
33
|
return;
|
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@ Object.freeze(EMPTYARRAY);
|
|
|
23
23
|
|
|
24
24
|
// Globals
|
|
25
25
|
global.F = global.Total = {};
|
|
26
|
-
global.DEBUG =
|
|
26
|
+
global.DEBUG = process.env.NODE_ENV !== 'production';
|
|
27
27
|
global.CONF = {};
|
|
28
28
|
global.REPO = {};
|
|
29
29
|
global.MAIN = {};
|
|
@@ -38,7 +38,7 @@ global.DEF = {};
|
|
|
38
38
|
|
|
39
39
|
F.id = '';
|
|
40
40
|
F.clusterid = '';
|
|
41
|
-
F.is5 = F.version =
|
|
41
|
+
F.is5 = F.version = 5017;
|
|
42
42
|
F.isBundle = false;
|
|
43
43
|
F.isLoaded = false;
|
|
44
44
|
F.version_header = '5';
|
package/mail.js
CHANGED
|
@@ -212,7 +212,7 @@ Message.prototype.send2 = function(callback) {
|
|
|
212
212
|
data.subject = self.subject;
|
|
213
213
|
data.type = self.type;
|
|
214
214
|
data.body = self.body;
|
|
215
|
-
data.priority = self.$
|
|
215
|
+
data.priority = self.$priority;
|
|
216
216
|
data.unsubscribe = self.$unsubscribe;
|
|
217
217
|
data.confidential = self.$confidential;
|
|
218
218
|
|
|
@@ -486,9 +486,25 @@ Mailer.send = function(opt, messages, callback) {
|
|
|
486
486
|
opt.port = 465;
|
|
487
487
|
|
|
488
488
|
if (!opt.server) {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
489
|
+
const err = new Error('No SMTP server configuration.');
|
|
490
|
+
let iscallback = false;
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
if (callback) {
|
|
494
|
+
iscallback = true;
|
|
495
|
+
callback(err);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
for (let m of obj.messages) {
|
|
499
|
+
if (m.$callback) {
|
|
500
|
+
iscallback = true;
|
|
501
|
+
m.$callback(err);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (!iscallback)
|
|
506
|
+
F.error(err, 'mail_smtp');
|
|
507
|
+
|
|
492
508
|
return self;
|
|
493
509
|
}
|
|
494
510
|
|
|
@@ -529,8 +545,17 @@ Mailer.send = function(opt, messages, callback) {
|
|
|
529
545
|
if (obj.try || err.stack.indexOf('ECONNRESET') !== -1)
|
|
530
546
|
return;
|
|
531
547
|
|
|
532
|
-
if (!obj.try && !is)
|
|
533
|
-
|
|
548
|
+
if (!obj.try && !is) {
|
|
549
|
+
let iscallback = false;
|
|
550
|
+
for (let m of obj.messages) {
|
|
551
|
+
if (m.$callback) {
|
|
552
|
+
iscallback = true;
|
|
553
|
+
m.$callback(err);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (!iscallback)
|
|
557
|
+
F.error(err, 'mail_smtp', opt.server);
|
|
558
|
+
}
|
|
534
559
|
|
|
535
560
|
if (obj === F.temporary.smtp[opt.server])
|
|
536
561
|
delete F.temporary.smtp[opt.server];
|
|
@@ -542,8 +567,17 @@ Mailer.send = function(opt, messages, callback) {
|
|
|
542
567
|
|
|
543
568
|
Mailer.destroy(obj);
|
|
544
569
|
|
|
545
|
-
if (!obj.try && !obj.callback)
|
|
546
|
-
|
|
570
|
+
if (!obj.try && !obj.callback) {
|
|
571
|
+
let iscallback = false;
|
|
572
|
+
for (let m of obj.messages) {
|
|
573
|
+
if (m.$callback) {
|
|
574
|
+
iscallback = true;
|
|
575
|
+
m.$callback(err);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (!iscallback)
|
|
579
|
+
F.error(err, 'mail_smtp', opt.server);
|
|
580
|
+
}
|
|
547
581
|
|
|
548
582
|
obj.callback && obj.callback(err);
|
|
549
583
|
obj.callback = null;
|
|
@@ -561,8 +595,17 @@ Mailer.send = function(opt, messages, callback) {
|
|
|
561
595
|
var err = F.TUtils.httpstatus(408);
|
|
562
596
|
Mailer.destroy(obj);
|
|
563
597
|
|
|
564
|
-
if (!obj.try && !obj.callback)
|
|
565
|
-
|
|
598
|
+
if (!obj.try && !obj.callback) {
|
|
599
|
+
let iscallback = false;
|
|
600
|
+
for (let m of obj.messages) {
|
|
601
|
+
if (m.$callback) {
|
|
602
|
+
iscallback = true;
|
|
603
|
+
m.$callback(err);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (!iscallback)
|
|
607
|
+
F.error(err, 'mail_smtp', opt.server);
|
|
608
|
+
}
|
|
566
609
|
|
|
567
610
|
obj.callback && obj.callback(err);
|
|
568
611
|
obj.callback = null;
|
|
@@ -850,11 +893,15 @@ Mailer.$send = function(obj, options, autosend) {
|
|
|
850
893
|
obj.logged = true;
|
|
851
894
|
Mailer.$writeline(obj, value);
|
|
852
895
|
} else {
|
|
853
|
-
|
|
896
|
+
const err2 = new Error('Forbidden.');
|
|
854
897
|
Mailer.destroy(obj);
|
|
855
|
-
obj.callback && obj.callback(
|
|
898
|
+
obj.callback && obj.callback(err2);
|
|
856
899
|
obj.callback = null;
|
|
857
|
-
|
|
900
|
+
for (let m of obj.messages) {
|
|
901
|
+
if (m.$callback)
|
|
902
|
+
m.$callback(err2);
|
|
903
|
+
}
|
|
904
|
+
Mailer.$events.error && !obj.try && Mailer.emit('error', err2, obj);
|
|
858
905
|
}
|
|
859
906
|
|
|
860
907
|
return;
|
|
@@ -876,23 +923,34 @@ Mailer.$send = function(obj, options, autosend) {
|
|
|
876
923
|
return;
|
|
877
924
|
}
|
|
878
925
|
|
|
879
|
-
|
|
926
|
+
const err = line;
|
|
927
|
+
let iscallback = false;
|
|
880
928
|
|
|
881
929
|
Mailer.$events.error && !obj.try && Mailer.emit('error', err, obj);
|
|
882
930
|
|
|
883
931
|
if (obj.messagecallback) {
|
|
932
|
+
iscallback = true;
|
|
884
933
|
obj.messagecallback(err, obj.instance);
|
|
885
934
|
obj.messagecallback = null;
|
|
886
935
|
}
|
|
887
936
|
|
|
888
937
|
if (obj.messagecallback2) {
|
|
938
|
+
iscallback = true;
|
|
889
939
|
obj.messagecallback2(err, obj.instance);
|
|
890
940
|
obj.messagecallback2 = null;
|
|
891
941
|
}
|
|
892
942
|
|
|
893
943
|
if (obj.messages.length) {
|
|
894
944
|
|
|
895
|
-
|
|
945
|
+
for (let m of obj.messages) {
|
|
946
|
+
if (m.$callback) {
|
|
947
|
+
iscallback = true;
|
|
948
|
+
m.$callback(err);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
if (!iscallback)
|
|
953
|
+
F.error(err, 'SMTP error');
|
|
896
954
|
|
|
897
955
|
// a problem
|
|
898
956
|
obj.buffer = [];
|
package/package.json
CHANGED
package/routing.js
CHANGED
|
@@ -37,12 +37,12 @@ function parseSizeTimeout(route, value) {
|
|
|
37
37
|
route.size = number;
|
|
38
38
|
break;
|
|
39
39
|
case 'kb':
|
|
40
|
-
number = number
|
|
40
|
+
number = number * 1024;
|
|
41
41
|
if (route.size < number)
|
|
42
42
|
route.size = number;
|
|
43
43
|
break;
|
|
44
44
|
case 'gb':
|
|
45
|
-
number =
|
|
45
|
+
number = number * 1024 * 1024 * 1024;
|
|
46
46
|
if (route.size < number)
|
|
47
47
|
route.size = number;
|
|
48
48
|
break;
|
|
@@ -321,14 +321,14 @@ Route.prototype.remove = function() {
|
|
|
321
321
|
case 'websocket':
|
|
322
322
|
index = F.routes.websockets.indexOf(self);
|
|
323
323
|
if (index !== -1)
|
|
324
|
-
F.routes.websockets.splice(index);
|
|
324
|
+
F.routes.websockets.splice(index, 1);
|
|
325
325
|
for (let conn of self.connections)
|
|
326
326
|
conn.destroy();
|
|
327
327
|
break;
|
|
328
328
|
case 'file':
|
|
329
329
|
index = F.routes.files.indexOf(self);
|
|
330
330
|
if (index !== -1)
|
|
331
|
-
F.routes.files.splice(index);
|
|
331
|
+
F.routes.files.splice(index, 1);
|
|
332
332
|
break;
|
|
333
333
|
default:
|
|
334
334
|
if (self.apiendpoint) {
|
|
@@ -337,14 +337,14 @@ Route.prototype.remove = function() {
|
|
|
337
337
|
if (Object.keys(self.parent.api).length == 0) {
|
|
338
338
|
index = F.routes.routes.indexOf(self.parent);
|
|
339
339
|
if (index !== -1)
|
|
340
|
-
F.routes.routes.splice(index);
|
|
340
|
+
F.routes.routes.splice(index, 1);
|
|
341
341
|
}
|
|
342
342
|
} else {
|
|
343
343
|
delete self.api[self.apiendpoint];
|
|
344
344
|
if (Object.keys(self.api).length == 0) {
|
|
345
345
|
index = F.routes.routes.indexOf(self);
|
|
346
346
|
if (index !== -1)
|
|
347
|
-
F.routes.routes.splice(index);
|
|
347
|
+
F.routes.routes.splice(index, 1);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
} else {
|
|
@@ -645,7 +645,7 @@ exports.lookupcors = function(ctrl) {
|
|
|
645
645
|
return false;
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
-
let origin = ctrl.headers.origin;
|
|
648
|
+
let origin = ctrl.headers.origin || '';
|
|
649
649
|
|
|
650
650
|
if (F.config.$cors !== '*' && !origin.endsWith(ctrl.headers.host)) {
|
|
651
651
|
|