-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (22 loc) · 825 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
const express = require('express');
const exphbs = require('express-handlebars');
const mongoose = require('mongoose');
require('dotenv').config();
const app = express();
const port = process.env.PORT || 80;
// Static Files
//app.use(express.static('public'));
// Templating Engine
app.engine('hbs', exphbs( {extname: '.hbs' }));
app.set('view engine', 'hbs');
app.use(express.urlencoded({extended: true}));
app.use(express.json())
// Connection Pool
mongoose.connect(process.env.MONGOURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true
}).then(() => console.log("connected to MONGO DB...")).catch(() => console.log(err));
const routes = require('./routes/routes')(app);
app.listen(port, () => console.log(`Listening on port ${port}`));