multy-stub/server/routers/kfu-m-24-1/sberhubproject/users/index.js
2024-12-28 11:02:11 +03:00

39 lines
866 B
JavaScript

const router = require('express').Router();
module.exports = router;
const data = require('./data/users.json');
router.get('/', (req, res) => {
//res.status(500).send({
// message: 'Internal server error'
//});
res.json(data)
});
router.get('/:id', (req, res) => {
//res.status(500).send({
// message: 'Internal server error'
//});
const userId = parseInt(req.params.id);
res.json(data.find(item => item.id = userId));
});
router.post('/', (req, res) => {
//res.status(500).send({
// message: 'Internal server error'
//});
const data = req.body;
res.status(200).send();
});
router.put('/:id', (req, res) => {
//res.status(500).send({
// message: 'Internal server error'
//});
const userId = parseInt(req.params.id);
const data = req.body;
res.status(200).send();
});