-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (23 loc) · 867 Bytes
/
app.js
File metadata and controls
33 lines (23 loc) · 867 Bytes
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
const express = require('express');
require('dotenv').config()
const morgan = require('morgan');
const bodyparser = require('body-parser');
const path = require('path');
const connectDB = require('./server/database/connection');
const app = express();
const PORT = process.env.PORT || 3000;
//log requests
app.use(morgan('tiny'));
// mongoDB Connection
connectDB();
//parse request to body-parser
app.use(bodyparser.urlencoded({ extended: true }));
//set view engine
app.set('view engine','ejs');
//load assets
app.use('/css',express.static(path.resolve(__dirname, 'assets/css')));
app.use('/js',express.static(path.resolve(__dirname, 'assets/js')));
app.use('/img',express.static(path.resolve(__dirname, 'assets/img')));
// Load Routers
app.use('/', require('./server/routes/router'));
app.listen(PORT, ()=> console.log(`Server started on PORT ${PORT}`));