From 214c6a3735bd80829ccec001c393979201679513 Mon Sep 17 00:00:00 2001 From: Mateus Malaquias Date: Mon, 14 May 2018 15:34:19 -0300 Subject: [PATCH] Initial structure for resume endpoints is working --- api/src/routes/index.js | 5 +++-- api/src/routes/resumes.routes.js | 13 +++++++++++-- api/src/server/factory.js | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api/src/routes/index.js b/api/src/routes/index.js index 3803310..3596690 100644 --- a/api/src/routes/index.js +++ b/api/src/routes/index.js @@ -1,7 +1,8 @@ -const {resumesFindAll} = require('./resumes.routes') +const {findAll, save} = require('./resumes.routes') const routes = (server) => { - server.get('/api/v1/resumes', resumesFindAll) + server.post('/api/v1/resumes', save) + server.get('/api/v1/resumes', findAll) } module.exports = routes diff --git a/api/src/routes/resumes.routes.js b/api/src/routes/resumes.routes.js index 0798435..a9e7fc3 100644 --- a/api/src/routes/resumes.routes.js +++ b/api/src/routes/resumes.routes.js @@ -1,7 +1,16 @@ const findAll = (req, res) => { - return res.send({message: `I'M A LIVE... lol`}) + return res.send([ + {id: 1, value: 'test 1'}, + {id: 2, value: 'test 2'} + ]) +} + +const save = (req, res) => { + const {name} = req.params + res.send(name) } module.exports = { - resumesFindAll: findAll + findAll: findAll, + save: save } diff --git a/api/src/server/factory.js b/api/src/server/factory.js index 7c87175..27bccb3 100644 --- a/api/src/server/factory.js +++ b/api/src/server/factory.js @@ -7,6 +7,7 @@ const factoryServer = () => { server.pre(cors.preflight) server.use(cors.actual) + server.use(restify.plugins.bodyParser()) routes(server)