-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (28 loc) · 1.23 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
require('dotenv').config()
const express =require('express');
const path = require('path');
const ejs = require('ejs');
const bodyParser = require('body-parser')
const app = express();
// ******************* Set Template Engine ***********************************//
app.set("view engine","ejs")
app.set('views', path.join(__dirname, 'views'))
console.log(app.get("view engine"))
// ************************ Database Connection **********************************//
const {connectMonggose} = require('./app/database/db')
connectMonggose();
// ************************* Assets ****************************************//
const publicPath = path.join(__dirname,"public");
app.use(express.static(publicPath));
app.use(express.static(__dirname + '/public'));
app.use( bodyParser.urlencoded({ extended: true }) );
app.use(express.urlencoded({ extended: false }))
app.use(express.json())
app.use('/uploads',express.static('uploads'));
// ***********************************Routes ********************************//
require('./routes/api')(app)
// ************************ Port Start ********************************//
const PORT = process.env.PORT || 2000;
app.listen(PORT,()=>{
console.log(`My server start on this port ${PORT}`)
})