-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (31 loc) · 961 Bytes
/
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
const path = require('path')
const express = require('express')
const port = process.env.PORT || 3000;
const moment = require('moment')
const favicon = require('serve-favicon');
//init app
const app = express()
//init local-moment
app.locals.moment = moment;
//loading favicon
app.use(favicon(path.join(__dirname, 'public', 'world-news.ico')))
//static file
app.use(express.static(path.join(__dirname, 'public')))
//set view-engine(EJS)
app.set('view engine', '.ejs')
app.set('views', './views')
app.use(express.urlencoded({ extended: true }));
//load routes
app.use('/', require('./routes/news'))
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`)
})
/* for deployment, use below code in package.json file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"scripts": {
"start": "node app.js"
* for local
~~~~~~~~~~~~~~~~~~~~~
"start": "node app.js",
"dev": "nodemon app.js"
*/