-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
54 lines (46 loc) · 1.13 KB
/
server.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
45
46
47
48
49
50
51
52
53
54
/**
* Module dependencies.
*/
const dotenv = require('dotenv');
const chalk = require('chalk');
const express = require("express")
const logger = require('morgan')
const bodyParser = require('body-parser');
const path = require('path');
const multer = require('multer');
const upload = multer({ dest: path.join(__dirname, 'upload') });
/**
* Load environment variables from .env file.
*/
dotenv.config({ path: '.env' });
/**
* Create Express server.
*/
const app = express()
/**
* Express Settings
*/
app.use(logger('dev'));
app.use(express.static('public'))
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'pug');
/**
* Database Connection
*/
require("./config/database")
/**
* Import lang files
*/
global.lang = require(`./locale/${process.env.LOCALE}`)
/**
* Import Routes
*/
require('./routes').run(app)
/**
* Listen Express server.
*/
app.listen(process.env.SERVER_PORT, (req, res) => {
console.log('%s App is running at http://localhost:%d in %s mode', chalk.green('✓'), process.env.SERVER_PORT, process.env.ENVIRONMENT);
console.log(' Press CTRL-C to stop\n');
})
module.exports = app;