-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (19 loc) · 906 Bytes
/
index.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
const app = require('express')();
const bodyParser = require('body-parser');
const todoNoteOps = require('./entities/TodoNote/operations');
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "OPTIONS, HEAD, GET, POST, PATCH, DELETE");
next();
});
// Se usa para poder revisar el contenido del body dentro de las peticiones http
app.use(bodyParser.json());
app.get('/', (req, res) => res.send('TODO api de Rodrigo'));
app.route('/todos')
.get(todoNoteOps.getAllTodoNotes)
.post(todoNoteOps.createNewTodoNote)
.patch(todoNoteOps.updateSpecificTodoNote)
.delete(todoNoteOps.deleteSpecificNote);
app.get('/todos/:documentId', todoNoteOps.getSpecificTodoNote);
app.listen(5000, () => console.log('Servidor levantado'));