Last active
June 18, 2019 16:33
-
-
Save haldarmahesh/a136764769e079c6fe554c1a6adb38f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
const employeeService = require('../service/employeeService'); | |
router.get('/api/employees', (req, res) => res.json(employeeService.getAll())); | |
router.get('/api/employees/:id', (req, res) => { | |
const employeeId = req.params.id; | |
return res.json(employeeService.getById(employeeId)); | |
}); | |
router.post('/api/employees', (req, res) => { | |
const newEmployee = req.body; | |
return res.json(employeeService.save(newEmployee)); | |
}); | |
router.delete('/api/employees/:id', (req, res) => { | |
const employeeId = req.params.id; | |
return res.json(employeeService.deleteById(employeeId)); // todo convert to do | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment