Skip to content

Commit 76c5d9f

Browse files
committed
New changes.
1 parent 4e1f511 commit 76c5d9f

4 files changed

Lines changed: 72 additions & 35 deletions

File tree

changes.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- added: config `nosql-logger` (default `true`) enables simple logs when re-indexing and cleaning
3838
- added: config `security.txt` for auto-generating security.txt content (more in docs)
3939
- added: config `default-proxy` for default web proxy server
40+
- added: config `allow-cache` disables clearing temporary cache (default: `false`)
4041
- added: `NOSQLSTORAGE(name)` alias for `NOSQL(name).storage`
4142
- added: `NOSQLINDEXES(name)` alias for `NOSQL(name).indexes`
4243
- added: `GUID()` a global alias for `U.GUID()`
@@ -100,6 +101,12 @@
100101
- fixed: `U.get()` a problem with path with `-`
101102
- fixed: `U.set()` a problem with path with `-`
102103

104+
- replaced: config `disable-clear-temporary-directory` to `allow-clear-temp : true|false`
105+
- replaced: config `disable-strict-server-certificate-validation` to `allow-ssc-validation : true|false`
106+
- replaced: config `default-websocket-request-length` to `default-websocket-maxlength`
107+
- replaced: config `default-request-length` to `default-request-maxlength`
108+
- replaced: config `default-maximum-file-descriptors` to `default-maxopenfiles`
109+
103110
- improved: `debug` mode timing with improved consumption
104111
- improved: performance (+20%) NoSQL embedded database
105112
- improved: reading performance (+5%) in `U.streamer()`

index.js

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ function Framework() {
610610
secret: Os.hostname() + '-' + Os.platform() + '-' + Os.arch(),
611611

612612
'security.txt': 'Contact: mailto:support@totaljs.com\nContact: https://www.totaljs.com/contact/',
613-
'default-xpoweredby': 'Total.js',
614613
'etag-version': '',
615614
'directory-src': '/.src/',
616615
'directory-bundles': '/bundles/',
@@ -651,16 +650,17 @@ function Framework() {
651650

652651
// 'static-accepts-custom': [],
653652

653+
'default-xpoweredby': 'Total.js',
654654
'default-layout': 'layout',
655655
'default-theme': '',
656656
'default-proxy': '',
657657

658658
// default maximum request size / length
659659
// default 10 kB
660-
'default-request-length': 10,
661-
'default-websocket-request-length': 2,
660+
'default-request-maxlength': 10,
661+
'default-websocket-maxlength': 2,
662662
'default-websocket-encodedecode': true,
663-
'default-maximum-file-descriptors': 0,
663+
'default-maxopenfiles': 0,
664664
'default-timezone': '',
665665
'default-root': '',
666666
'default-response-maxage': '11111111',
@@ -694,8 +694,8 @@ function Framework() {
694694
'allow-debug': false,
695695
'allow-head': false,
696696
'allow-filter-errors': true,
697-
'disable-strict-server-certificate-validation': true,
698-
'disable-clear-temporary-directory': false,
697+
'allow-clear-temp': true,
698+
'allow-ssc-validation': false,
699699
'nosql-worker': false,
700700
'nosql-inmemory': null, // String Array
701701
'nosql-cleaner': 1440,
@@ -705,9 +705,9 @@ function Framework() {
705705
// All values are in minutes
706706
'default-interval-clear-resources': 20,
707707
'default-interval-clear-cache': 10,
708+
'default-interval-clear-dnscache': 120,
708709
'default-interval-precompile-views': 61,
709710
'default-interval-websocket-ping': 3,
710-
'default-interval-clear-dnscache': 120,
711711
'default-interval-uptodate': 5
712712
};
713713

@@ -2207,7 +2207,7 @@ F.web = F.route = function(url, funcExecute, flags, length, language) {
22072207
r.flags2 = flags_to_object(flags);
22082208
r.method = method;
22092209
r.execute = funcExecute;
2210-
r.length = (length || F.config['default-request-length']) * 1024;
2210+
r.length = (length || F.config['default-request-maxlength']) * 1024;
22112211
r.middleware = middleware;
22122212
r.timeout = timeout === undefined ? (isDELAY ? 0 : F.config['default-request-timeout']) : timeout;
22132213
r.isGET = flags.indexOf('get') !== -1;
@@ -2853,7 +2853,7 @@ F.websocket = function(url, funcInitialize, flags, length) {
28532853
r.onInitialize = funcInitialize;
28542854
r.protocols = protocols || EMPTYARRAY;
28552855
r.allow = allow || [];
2856-
r.length = (length || F.config['default-websocket-request-length']) * 1024;
2856+
r.length = (length || F.config['default-websocket-maxlength']) * 1024;
28572857
r.isWEBSOCKET = true;
28582858
r.MEMBER = membertype;
28592859
r.isJSON = isJSON;
@@ -5192,7 +5192,8 @@ F.$onParseXML = function(req) {
51925192
* @return {Object}
51935193
*/
51945194
F.onParseJSON = function(value) {
5195-
return JSON.parse(value);
5195+
if (value)
5196+
return JSON.parse(value);
51965197
};
51975198
F.onParseJSON.$def = true;
51985199

@@ -6904,18 +6905,21 @@ F.custom = function(mode, http, request, response, options) {
69046905
F.console = function() {
69056906
var memory = process.memoryUsage();
69066907
console.log('====================================================');
6907-
console.log('PID : ' + process.pid);
6908-
console.log('Node.js : ' + process.version);
6909-
console.log('Total.js : v' + F.version_header);
6910-
console.log('OS : ' + Os.platform() + ' ' + Os.release());
6911-
F.config['nosql-worker'] && console.log('NoSQL PID : ' + framework_nosql.pid());
6912-
console.log('Memory : ' + memory.heapUsed.filesize(2) + ' / ' + memory.heapTotal.filesize(2));
6908+
console.log('PID : ' + process.pid);
6909+
console.log('Node.js : ' + process.version);
6910+
console.log('Total.js : v' + F.version_header);
6911+
console.log('OS : ' + Os.platform() + ' ' + Os.release());
6912+
F.config['nosql-worker'] && console.log('NoSQL PID : ' + framework_nosql.pid());
6913+
console.log('Memory : ' + memory.heapUsed.filesize(2) + ' / ' + memory.heapTotal.filesize(2));
6914+
console.log('====================================================');
6915+
console.log('Name : ' + F.config.name);
6916+
console.log('Version : ' + F.config.version);
6917+
console.log('Author : ' + F.config.author);
6918+
console.log('Date : ' + NOW.format('yyyy-MM-dd HH:mm:ss'));
6919+
console.log('Mode : ' + (F.config.debug ? 'debug' : 'release'));
69136920
console.log('====================================================');
6914-
console.log('Name : ' + F.config.name);
6915-
console.log('Version : ' + F.config.version);
6916-
console.log('Author : ' + F.config.author);
6917-
console.log('Date : ' + NOW.format('yyyy-MM-dd HH:mm:ss'));
6918-
console.log('Mode : ' + (F.config.debug ? 'debug' : 'release'));
6921+
console.log('Directory : ' + process.cwd());
6922+
console.log('node_modules : ' + PATHMODULES);
69196923
console.log('====================================================\n');
69206924
if (!F.isWorker) {
69216925
console.log('{2}://{0}:{1}/'.format(F.ip, F.port, F.isHTTPS ? 'https' : 'http'));
@@ -7828,12 +7832,11 @@ F.test = function() {
78287832
* @return {Framework}
78297833
*/
78307834
F.clear = function(callback, isInit) {
7831-
78327835
var dir = F.path.temp();
78337836
var plus = F.id ? 'i-' + F.id + '_' : '';
78347837

78357838
if (isInit) {
7836-
if (F.config['disable-clear-temporary-directory']) {
7839+
if (!F.config['allow-clear-temp']) {
78377840
// clears only JS and CSS files
78387841
U.ls(dir, function(files) {
78397842
F.unlink(files, function() {
@@ -8686,16 +8689,27 @@ F.$configure_configs = function(arr, rewrite) {
86868689
subtype = '';
86878690

86888691
switch (name) {
8689-
case 'default-cors-maxage':
86908692
case 'default-request-length':
8693+
OBSOLETE(name, 'You need to use "default-request-maxlength"');
8694+
obj['default-request-maxlength'] = U.parseInt(value);
8695+
break;
86918696
case 'default-websocket-request-length':
8697+
OBSOLETE(name, 'You need to use "default-websocket-maxlength"');
8698+
obj['default-websocket-maxlength'] = U.parseInt(value);
8699+
break;
8700+
case 'default-maximum-file-descriptors':
8701+
OBSOLETE(name, 'You need to use "default-maxopenfiles"');
8702+
obj['default-maxopenfiles'] = U.parseInt(value);
8703+
break;
8704+
case 'default-cors-maxage':
86928705
case 'default-request-timeout':
8706+
case 'default-request-maxlength':
8707+
case 'default-websocket-maxlength':
86938708
case 'default-interval-clear-cache':
86948709
case 'default-interval-clear-resources':
86958710
case 'default-interval-precompile-views':
86968711
case 'default-interval-uptodate':
86978712
case 'default-interval-websocket-ping':
8698-
case 'default-maximum-file-descriptors':
86998713
case 'default-interval-clear-dnscache':
87008714
case 'default-dependency-timeout':
87018715
case 'nosql-cleaner':
@@ -8743,18 +8757,28 @@ F.$configure_configs = function(arr, rewrite) {
87438757
obj['allow-static-files'] = true;
87448758
break;
87458759

8760+
case 'disable-clear-temporary-directory':
8761+
OBSOLETE('disable-clear-temporary-directory', 'You need to use "allow-clear-temp : true|false"');
8762+
obj['allow-clear-temp'] = !(value.toLowerCase() === 'true' || value === '1' || value === 'on');
8763+
break;
8764+
8765+
case 'disable-strict-server-certificate-validation':
8766+
OBSOLETE('disable-strict-server-certificate-validation', 'You need to use "allow-ssc-validation : true|false"');
8767+
obj['allow-ssc-validation'] = !(value.toLowerCase() === 'true' || value === '1' || value === 'on');
8768+
break;
8769+
87468770
case 'allow-compile-html':
87478771
case 'allow-compile-script':
87488772
case 'allow-compile-style':
8773+
case 'allow-ssc-validation':
87498774
case 'allow-debug':
87508775
case 'allow-gzip':
87518776
case 'allow-performance':
87528777
case 'allow-static-files':
87538778
case 'allow-websocket':
8754-
case 'disable-strict-server-certificate-validation':
8755-
case 'disable-clear-temporary-directory':
8756-
case 'trace':
8779+
case 'allow-clear-temp':
87578780
case 'allow-cache-snapshot':
8781+
case 'trace':
87588782
case 'nosql-worker':
87598783
case 'nosql-logger':
87608784
obj[name] = value.toLowerCase() === 'true' || value === '1' || value === 'on';
@@ -8829,7 +8853,7 @@ F.$configure_configs = function(arr, rewrite) {
88298853
F.config['nosql-inmemory'] && F.config['nosql-inmemory'].forEach(n => framework_nosql.inmemory(n));
88308854
accepts && accepts.length && accepts.forEach(accept => F.config['static-accepts'][accept] = true);
88318855

8832-
if (F.config['disable-strict-server-certificate-validation'] === true)
8856+
if (F.config['allow-ssc-validation'] === false)
88338857
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
88348858

88358859
if (F.config['allow-performance'])
@@ -12057,10 +12081,16 @@ Controller.prototype.custom = function() {
1205712081
* @return {Controller}
1205812082
*/
1205912083
Controller.prototype.noClear = function(enable) {
12084+
OBSOLETE('controller.noClear()', 'You need to use controller.autoclear(false)');
1206012085
this.req._manual = enable === undefined ? true : enable;
1206112086
return this;
1206212087
};
1206312088

12089+
Controller.prototype.autoclear = function(enable) {
12090+
this.req._manual = enable === true;
12091+
return this;
12092+
};
12093+
1206412094
Controller.prototype.html = function(body, headers) {
1206512095
return this.content(body, 'text/html', headers);
1206612096
};
@@ -16188,7 +16218,7 @@ process.on('uncaughtException', function(e) {
1618816218
});
1618916219

1619016220
function fsFileRead(filename, callback, a, b, c) {
16191-
U.queue('F.files', F.config['default-maximum-file-descriptors'], function(next) {
16221+
U.queue('F.files', F.config['default-maxopenfiles'], function(next) {
1619216222
Fs.readFile(filename, function(err, result) {
1619316223
next();
1619416224
callback(err, result, a, b, c);
@@ -16197,7 +16227,7 @@ function fsFileRead(filename, callback, a, b, c) {
1619716227
}
1619816228

1619916229
function fsFileExists(filename, callback, a, b, c) {
16200-
U.queue('F.files', F.config['default-maximum-file-descriptors'], function(next) {
16230+
U.queue('F.files', F.config['default-maxopenfiles'], function(next) {
1620116231
Fs.lstat(filename, function(err, stats) {
1620216232
next();
1620316233
callback(!err && stats.isFile(), stats ? stats.size : 0, stats ? stats.isFile() : false, stats, a, b, c);
@@ -16226,7 +16256,7 @@ function fsStreamRead(filename, options, callback, res) {
1622616256
} else
1622716257
opt = HEADERS.fsStreamRead;
1622816258

16229-
U.queue('F.files', F.config['default-maximum-file-descriptors'], function(next) {
16259+
U.queue('F.files', F.config['default-maxopenfiles'], function(next) {
1623016260
var stream = Fs.createReadStream(filename, opt);
1623116261
stream.on('error', NOOP);
1623216262
callback(stream, next, res);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test": "test"
1919
},
2020
"engines": {
21-
"node": ">=4.0.0"
21+
"node": ">=8.0.0"
2222
},
2323
"keywords": ["total", "iot", "framework", "web", "websocket", "mvc", "controller", "view", "angular.js", "upload", "picture", "graphicsmagick", "imagemagick", "eshop", "blog", "forum", "chat", "game", "nosql", "database", "streaming", "live", "server sent events", "sse", "multipart", "x-mixed-replace"],
2424
"license": "MIT",
@@ -96,7 +96,7 @@
9696
"name": "Pedro Costa",
9797
"email": "pedro@pmcdigital.pt"
9898
}],
99-
"version": "3.0.0-56",
99+
"version": "3.0.0-57",
100100
"homepage": "http://www.totaljs.com",
101101
"bugs": {
102102
"url": "https://github.com/totaljs/framework/issues",

utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,7 @@ String.prototype.parseConfig = function(def, onerr) {
33263326
if (!str || str[0] === '#' || str.substring(0, 2) === '//')
33273327
continue;
33283328

3329-
index = str.indexOf(' :');
3329+
index = str.indexOf(':');
33303330
if (index === -1) {
33313331
index = str.indexOf('\t:');
33323332
if (index === -1)

0 commit comments

Comments
 (0)