Базовые сетевые запросы
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
const router = require('express').Router();
|
||||
|
||||
const listRouter = require('./list');
|
||||
module.exports = router;
|
||||
|
||||
const delay =
|
||||
(ms = 1000) =>
|
||||
(req, res, next) => {
|
||||
setTimeout(next, ms);
|
||||
};
|
||||
|
||||
router.use(delay());
|
||||
router.use('/list', listRouter);
|
||||
|
||||
7
stubs/api/list/data/list.json
Normal file
7
stubs/api/list/data/list.json
Normal file
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{ "id": 1, "title": "title", "description": "description" },
|
||||
{ "id": 2, "title": "title", "description": "description" },
|
||||
{ "id": 3, "title": "title", "description": "description" },
|
||||
{ "id": 4, "title": "title", "description": "description" },
|
||||
{ "id": 5, "title": "title", "description": "description" }
|
||||
]
|
||||
12
stubs/api/list/index.js
Normal file
12
stubs/api/list/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const router = require('express').Router();
|
||||
|
||||
module.exports = router;
|
||||
|
||||
const data = require('./data/list.json');
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
res.send(data);
|
||||
// res.status(500).send({
|
||||
// message: 'Internal server error'
|
||||
// });
|
||||
});
|
||||
Reference in New Issue
Block a user