Добавил комарессию в express

This commit is contained in:
Book Pauk
2019-01-03 21:44:44 +07:00
parent cbda053ef9
commit 8e0d52bc9d
3 changed files with 42 additions and 2 deletions

39
package-lock.json generated
View File

@@ -2175,6 +2175,38 @@
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
"dev": true
},
"compressible": {
"version": "2.0.15",
"resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.15.tgz",
"integrity": "sha512-4aE67DL33dSW9gw4CI2H/yTxqHLNcxp0yS6jB+4h+wr3e43+1z7vm0HU9qXOH8j+qjKuL8+UtkOxYQSMq60Ylw==",
"requires": {
"mime-db": ">= 1.36.0 < 2"
}
},
"compression": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/compression/-/compression-1.7.3.tgz",
"integrity": "sha512-HSjyBG5N1Nnz7tF2+O7A9XUhyjru71/fwgNb7oIsEVHR0WShfs2tIS/EySLgiTe98aOK18YDlMXpzjCXY/n9mg==",
"requires": {
"accepts": "~1.3.5",
"bytes": "3.0.0",
"compressible": "~2.0.14",
"debug": "2.6.9",
"on-headers": "~1.0.1",
"safe-buffer": "5.1.2",
"vary": "~1.1.2"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -2182,7 +2214,7 @@
},
"concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"resolved": "http://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"dev": true,
"requires": {
@@ -6260,6 +6292,11 @@
"ee-first": "1.1.1"
}
},
"on-headers": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz",
"integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",

View File

@@ -51,6 +51,7 @@
"dependencies": {
"axios": "^0.18.0",
"bluebird": "^3.5.3",
"compression": "^1.7.3",
"element-ui": "^2.4.11",
"express": "^4.16.4",
"lodash": "^4.17.11",

View File

@@ -5,6 +5,7 @@ initLogger(config);
const log = getLog();
const express = require('express');
const compression = require('compression');
const app = express();
const SqliteConnectionPool = require('./core/SqliteConnectionPool');
@@ -20,7 +21,8 @@ async function main() {
require(devFileName).webpackDevMiddleware(app);
}
app.use(express.static(config.publicDir));
app.use(compression({ level: 1 }));
app.use(express.static(config.publicDir, { maxAge: '1d' }));
app.use(express.json());
require('./routes').initRoutes(app, connPool, config);