-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (27 loc) · 1 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
const express = require('express');
const dotenv = require('dotenv');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const path = require('path');
const connectDB = require("./server/database/connection");
const app = express();
//Secret info bifurcated from the server.
dotenv.config( { path :'config.env'} )
const PORT = process.env.PORT||8080;
//log posts
app.use(morgan('tiny'));
//mongodb conncetion *
connectDB();
//parse request to bodyParser
app.use(bodyParser.urlencoded({extended:true}));
//set view engine for ejs usage
app.set("view engine","ejs");
//load assets
app.use('/css',express.static(path.resolve(__dirname,"assets/css")))
app.use('/img',express.static(path.resolve(__dirname,"assets/img")))
app.use('/js' ,express.static(path.resolve(__dirname,"assets/js")))
//load router
app.use('/', require("./server/routes/router"));
app.listen(PORT , (req,res)=>{
console.log(`Server is running on http://localhost:${PORT}`);
})