forked from abelardovaje/mean-stack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
44 lines (37 loc) · 1.53 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
var express = require('express'),
ENV = require('node-env-file')(__dirname + '/.env'), // Load .env in the root directory of the this project
app = express();
// Get environment properties from a .env file for local development
app.ENV = ENV;
// Get port in .env or else use default port `3000`
app.ENV.NODE_PORT = app.ENV.NODE_PORT || 3000;
// If the development is for testing purpose or development. Use 'local'
if (app.ENV.NODE_DEVELOPMENT === 'local') {
app.ENV.NODE_URL += ':' + app.ENV.NODE_PORT;
}
// Gzip compression
require('./config/lib/compress')(app);
// Libraries for client-side
app.use('/bower_components', express.static(__dirname + '/bower_components'));
// Assets
app.use('/public', express.static(__dirname + '/public'));
// HTML Files
app.use('/views', express.static(__dirname + '/resources/views'));
// Helpers that can be use globally in the server
require('./config/lib/helpers');
// This library uses req.body for requests like POST method, etc.
require('./config/lib/body-parser')(app);
// This library uses for security purposes like session, crsf, passport, and helmet.
require('./config/lib/middleware')(app);
// Set csrf token in cookie
require('./config/lib/csrf')(app);
// Centralized error handler
require('./config/lib/handler')(app);
// Database configuration
require('./config/lib/mongoose')(app);
// Set of routes in an application
require('./config/lib/routes')(app);
// Passport configuration
require('./config/lib/passport')(app);
module.exports = app;