mirror of https://github.com/vladmandic/human
update dev server
parent
6b1734088d
commit
96a2b0a1b0
File diff suppressed because one or more lines are too long
|
@ -417,7 +417,7 @@
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"package.json": {
|
"package.json": {
|
||||||
"bytes": 2403,
|
"bytes": 2459,
|
||||||
"imports": []
|
"imports": []
|
||||||
},
|
},
|
||||||
"src/human.ts": {
|
"src/human.ts": {
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -51,7 +51,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",
|
"start": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",
|
||||||
"lint": "eslint src/*.js demo/*.js",
|
"lint": "eslint src/*.js demo/*.js",
|
||||||
"dev": "npm install && node server/dev.js",
|
"dev": "npm install && node server/serve.js",
|
||||||
"build": "rimraf dist/* && rimraf types/* && node server/build.js && node server/changelog.js",
|
"build": "rimraf dist/* && rimraf types/* && node server/build.js && node server/changelog.js",
|
||||||
"update": "npm update --depth 20 --force && npm dedupe && npm prune && npm audit"
|
"update": "npm update --depth 20 --force && npm dedupe && npm prune && npm audit"
|
||||||
},
|
},
|
||||||
|
|
|
@ -173,7 +173,7 @@ async function getStats(metafile) {
|
||||||
|
|
||||||
// rebuild typings
|
// rebuild typings
|
||||||
function compile(fileNames, options) {
|
function compile(fileNames, options) {
|
||||||
log.info('Compile:', fileNames);
|
log.info('Compile typings:', fileNames);
|
||||||
const program = ts.createProgram(fileNames, options);
|
const program = ts.createProgram(fileNames, options);
|
||||||
const emit = program.emit();
|
const emit = program.emit();
|
||||||
const diag = ts
|
const diag = ts
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
- passthrough data compression
|
- passthrough data compression
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const process = require('process');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
@ -31,15 +30,17 @@ const options = {
|
||||||
default: 'demo/index.html',
|
default: 'demo/index.html',
|
||||||
httpPort: 10030,
|
httpPort: 10030,
|
||||||
httpsPort: 10031,
|
httpsPort: 10031,
|
||||||
|
insecureHTTPParser: false,
|
||||||
|
minElapsed: 2,
|
||||||
monitor: ['package.json', 'config.js', 'demo', 'src'],
|
monitor: ['package.json', 'config.js', 'demo', 'src'],
|
||||||
};
|
};
|
||||||
|
|
||||||
// just some predefined mime types
|
// just some predefined mime types
|
||||||
const mime = {
|
const mime = {
|
||||||
'.html': 'text/html',
|
'.html': 'text/html; charset=utf-8',
|
||||||
'.js': 'text/javascript',
|
'.js': 'text/javascript; charset=utf-8',
|
||||||
'.css': 'text/css',
|
'.css': 'text/css; charset=utf-8',
|
||||||
'.json': 'application/json',
|
'.json': 'application/json; charset=utf-8',
|
||||||
'.png': 'image/png',
|
'.png': 'image/png',
|
||||||
'.jpg': 'image/jpg',
|
'.jpg': 'image/jpg',
|
||||||
'.gif': 'image/gif',
|
'.gif': 'image/gif',
|
||||||
|
@ -47,15 +48,16 @@ const mime = {
|
||||||
'.svg': 'image/svg+xml',
|
'.svg': 'image/svg+xml',
|
||||||
'.wav': 'audio/wav',
|
'.wav': 'audio/wav',
|
||||||
'.mp4': 'video/mp4',
|
'.mp4': 'video/mp4',
|
||||||
'.woff': 'application/font-woff',
|
'.woff': 'font/woff',
|
||||||
'.ttf': 'application/font-ttf',
|
'.woff2': 'font/woff2',
|
||||||
|
'.ttf': 'font/ttf',
|
||||||
'.wasm': 'application/wasm',
|
'.wasm': 'application/wasm',
|
||||||
};
|
};
|
||||||
|
|
||||||
let last = Date.now();
|
let last = Date.now();
|
||||||
async function buildAll(evt, msg) {
|
async function buildAll(evt, msg) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if ((now - last) > 2) build.build(evt, msg);
|
if ((now - last) > options.minElapsed) build.build(evt, msg);
|
||||||
else log.state('Build: merge event file', msg, evt);
|
else log.state('Build: merge event file', msg, evt);
|
||||||
last = now;
|
last = now;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +116,7 @@ async function httpRequest(req, res) {
|
||||||
const accept = req.headers['accept-encoding'] ? req.headers['accept-encoding'].includes('br') : false; // does target accept brotli compressed data
|
const accept = req.headers['accept-encoding'] ? req.headers['accept-encoding'].includes('br') : false; // does target accept brotli compressed data
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
// 'Content-Length': result.stat.size, // not using as it's misleading for compressed streams
|
// 'Content-Length': result.stat.size, // not using as it's misleading for compressed streams
|
||||||
'Content-Language': 'en', 'Content-Type': contentType, 'Content-Encoding': accept ? 'br' : '', 'Last-Modified': result.stat.mtime, 'Cache-Control': 'no-cache', 'X-Powered-By': `NodeJS/${process.version}`,
|
'Content-Language': 'en', 'Content-Type': contentType, 'Content-Encoding': accept ? 'br' : '', 'Last-Modified': result.stat.mtime, 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff',
|
||||||
});
|
});
|
||||||
const compress = zlib.createBrotliCompress({ params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }); // instance of brotli compression with level 5
|
const compress = zlib.createBrotliCompress({ params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }); // instance of brotli compression with level 5
|
||||||
const stream = fs.createReadStream(result.file);
|
const stream = fs.createReadStream(result.file);
|
Loading…
Reference in New Issue