From 18dc0c63c39d09c025bd1bdb19c2af818ad767f5 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Mon, 13 Apr 2015 02:05:01 +0200 Subject: [PATCH] Utilisation de la compression --- app/routes.js | 10 ++++++++++ package.json | 1 + 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/app/routes.js b/app/routes.js index ce3e23c..1fd4ccd 100644 --- a/app/routes.js +++ b/app/routes.js @@ -2,9 +2,19 @@ var path = require('path'); var api = require('./routes/ApiRtes'); var favicon = require('serve-favicon'); var express = require('express'); +var compression = require('compression'); module.exports = function (app) { + app.use(compression({ + filter: function shouldCompress(req, res) { + if (req.headers['x-no-compression']) { + return false; + } + return compression.filter(req, res); + } + })); + // Statique app.use(favicon(path.normalize(__dirname + '/../public/favicon.ico'))); app.use(express.static(path.normalize(__dirname + '/../public'))); diff --git a/package.json b/package.json index 799f334..619a01a 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "dependencies": { "async": "^0.9.0", "body-parser": "^1.12.2", + "compression": "^1.4.3", "connect-mongo": "^0.8.0", "cookie-parser": "^1.3.4", "express": "^4.12.3", -- libgit2 0.21.2