Commit 18dc0c63c39d09c025bd1bdb19c2af818ad767f5

Authored by Geoffrey PREUD'HOMME
1 parent fb8f1174

Utilisation de la compression

Showing 2 changed files with 11 additions and 0 deletions   Show diff stats
app/routes.js
... ... @@ -2,9 +2,19 @@ var path = require('path');
2 2 var api = require('./routes/ApiRtes');
3 3 var favicon = require('serve-favicon');
4 4 var express = require('express');
  5 +var compression = require('compression');
5 6  
6 7 module.exports = function (app) {
7 8  
  9 + app.use(compression({
  10 + filter: function shouldCompress(req, res) {
  11 + if (req.headers['x-no-compression']) {
  12 + return false;
  13 + }
  14 + return compression.filter(req, res);
  15 + }
  16 + }));
  17 +
8 18 // Statique
9 19 app.use(favicon(path.normalize(__dirname + '/../public/favicon.ico')));
10 20 app.use(express.static(path.normalize(__dirname + '/../public')));
... ...
package.json
... ... @@ -5,6 +5,7 @@
5 5 "dependencies": {
6 6 "async": "^0.9.0",
7 7 "body-parser": "^1.12.2",
  8 + "compression": "^1.4.3",
8 9 "connect-mongo": "^0.8.0",
9 10 "cookie-parser": "^1.3.4",
10 11 "express": "^4.12.3",
... ...