-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (17 loc) · 694 Bytes
/
server.js
File metadata and controls
24 lines (17 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
const mongoose = require('mongoose');
const Task = require('./api/models/todoListModel');
const bodyParser = require('body-parser');
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/Tododb', {useNewUrlParser: true, useUnifiedTopology: true});
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
const routes = require('./api/routes/todoListRoutes');
routes(app);
app.use((req, res) => {
res.status(404).send({url: req.originalUrl + ' not found'})
});
app.listen(port);
console.log('todo list RESTful API server started on: ' + port);