udemy-node-todo-app/server/server.js
Tyrel Souza 9c7041a80f tests
2017-11-29 23:15:25 -05:00

29 lines
543 B
JavaScript

var express = require('express')
var bodyParser = require('body-parser')
var {mongoose} = require('./db/mongoose')
var {User} = require('./models/user')
var {Todo} = require('./models/todo')
var app = express();
app.use(bodyParser.json());
app.post('/todos', (req, res) => {
var todo = new Todo({
text: req.body.text
});
todo.save().then((doc) => {
return res.send(doc);
}, (e) => {
return res.status(400).send(e);
});
});
app.listen(8888, () => {
console.log("Started on port 8888");
});
module.exports = {app}