-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
46 lines (32 loc) · 951 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
44
45
46
const express = require('express');
const app = express();
require('dotenv/config');
const expressSession = require('express-session');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const path = require('path');
mongoose.connect(process.env.MONGODB,({
useNewUrlParser:true,
useCreateIndex:true,
useUnifiedTopology:true
}));
let db = mongoose.connection;
db.on('error',(err)=>{
console.log(err);
});
db.once('open',()=>{
console.log('Hola Amigoes youre now connected to backend bro');
});
app.set('view engine','ejs');
app.use(express.static(path.join(__dirname,'/public')));
app.use(bodyParser.urlencoded({extended:false}));
app.use(expressSession({
secret:'A keyboard cat',
saveUninitialized:true,
resave:true
}));
app.use('/',require('./routes/index'));
const port = process.env.PORT || 3000;
app.listen(port,()=>{
console.log(`Okay I am On port ${port}`);
});