-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (37 loc) · 1.13 KB
/
index.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
const express = require('express')
const favicon = require('express-favicon')
const path = require('path')
const moment = require('moment')
const debug = require('debug')('app')
require('dotenv').config()
const {
DEBUG,
PORT
} = require('./constants')
if (DEBUG)
{
debug('> Started:\t\t', new Date().toLocaleString())
debug('DEBUG\t\t\t', DEBUG)
debug('PORT\t\t\t', PORT)
}
if (!PORT)
return debug('> Set the WEB environment variables first.')
// WEB & API SERVER ----------------------------------
const app = express()
// PUG -----------------------------------------------
app.use(express.static('public'))
app.set('view engine', 'pug')
// FAVICON
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')))
// REGISTER OUR ROUTES -------------------------------
// routes for the open web
app.use('/', require('./routes'))
// SERVER UP -----------------------------------------
app.listen(PORT, () => {
debug(`> Magic happens on port ${PORT}`) // eslint-disable-line
})
process.on('SIGINT', function() {
debug('> Bye bye! Have a nice day ;-)')
debug('> Closed:\t\t', new Date().toLocaleString())
process.exit()
})