Skip to content

Commit a51f94c

Browse files
committed
Prepared app for deployment
1 parent bc5c39b commit a51f94c

File tree

15 files changed

+617
-7043
lines changed

15 files changed

+617
-7043
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules/
22
*.env
33
.parcel-cache
4-
.cache
4+
.cache/

app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const mongoSanitize = require('express-mongo-sanitize');
77
const xss = require('xss-clean');
88
const hpp = require('hpp');
99
const cookieParser = require('cookie-parser');
10+
const compression = require('compression');
1011

1112
const AppError = require('./utils/appError');
1213
const globalErrorHandler = require('./controllers/errorController');
@@ -66,6 +67,9 @@ app.use(
6667
})
6768
);
6869

70+
// compress responses
71+
app.use(compression());
72+
6973
// Test middleware
7074
app.use((req, res, next) => {
7175
req.requestTime = new Date().toISOString();

controllers/viewController.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ exports.getMyTours = catchAsync(async (req, res, next) => {
6262
// 1) Find all bookings
6363
const bookings = await Bookings.find({ user: req.user.id });
6464

65-
console.log(bookings);
66-
6765
// 2) Find tours with the returned IDs
6866
const tourIDs = bookings.map(el => el.tour);
6967
const tours = await Tour.find({ _id: { $in: tourIDs } });

dev-data/data/import-dev-data.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ const importAppointments = async () => {
8787
});
8888
});
8989

90-
console.log(data);
9190
await Appointment.create(data);
9291

9392
console.log('Appointments successfully loaded');

models/tokenModel.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ tokenSchema.methods.createSignupToken = function() {
2020
.update(signupToken)
2121
.digest('hex');
2222

23-
console.log(this);
24-
2523
return signupToken;
2624
};
2725

models/tourModel.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ tourSchema.pre(/^find/, function(next) {
168168
next();
169169
});
170170

171-
tourSchema.post(/^find/, function(docs, next) {
172-
console.log(`Query took ${Date.now() - this.start} milliseconds`);
173-
next();
174-
});
171+
// tourSchema.post(/^find/, function(docs, next) {
172+
// console.log(`Query took ${Date.now() - this.start} milliseconds`);
173+
// next();
174+
// });
175175

176176
// Populate Normalized Data Model
177177
tourSchema.pre(/^find/, function(next) {

package-lock.json

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start:prod": "cross-env NODE_ENV=production nodemon server.js",
99
"debug": "ndb server.js",
1010
"watch:js": "parcel watch ./public/js/index.js",
11-
"build:js": "parcel watch ./public/js/index.js"
11+
"build:js": "parcel build ./public/js/index.js"
1212
},
1313
"targets": {
1414
"app": {}
@@ -19,6 +19,7 @@
1919
"@babel/polyfill": "^7.12.1",
2020
"axios": "^1.5.1",
2121
"bcryptjs": "^2.4.3",
22+
"compression": "^1.7.4",
2223
"cookie-parser": "^1.4.6",
2324
"core-js": "^3.33.0",
2425
"dotenv": "^16.3.1",

0 commit comments

Comments
 (0)