-
Notifications
You must be signed in to change notification settings - Fork 8
/
server.js
29 lines (23 loc) · 822 Bytes
/
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
const express = require('express');
const mustacheExpress = require('mustache-express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const routes = require('./routes/routes')
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://mongo:27017/mongoose_express_todos', {
// mongo in above url is the container
useNewUrlParser: true
}).then(() => {
console.log('Database connected')
});
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
const mustacheExpressInstance = mustacheExpress();
mustacheExpressInstance.cache = null;
app.engine('mustache', mustacheExpressInstance);
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.use('/', routes);
app.listen(3000, () => {
console.log('Server has started')
})