Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rachana gzip compression #1186

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"cheerio": "^1.0.0-rc.12",
"compression": "^1.7.5",
"cors": "^2.8.4",
"cron": "^1.8.2",
"dotenv": "^5.0.1",
Expand Down
8 changes: 8 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const express = require('express');
const Sentry = require('@sentry/node');
const compression = require('compression'); // Import compression

const app = express();
const logger = require('./startup/logger');
Expand All @@ -10,6 +11,13 @@ logger.init();
// The request handler must be the first middleware on the app
app.use(Sentry.Handlers.requestHandler());

// Gzip compression - start
app.use(compression({
level: 6, // Compression level (0 = no compression, 9 = max compression)
threshold: 0, // Compress responses larger than 1KB
}))
// Gzip compression - end

require('./startup/cors')(app);
require('./startup/bodyParser')(app);
require('./startup/middleware')(app);
Expand Down
Loading