2024-11-03 12:23:47 +03:00
|
|
|
/* eslint-disable no-undef */
|
|
|
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
2024-10-19 12:07:17 +03:00
|
|
|
const router = require('express').Router();
|
|
|
|
|
2024-12-01 12:17:04 +03:00
|
|
|
const STUBS = require('./admin').STUBS;
|
2024-12-01 11:51:52 +03:00
|
|
|
|
2024-12-01 12:17:04 +03:00
|
|
|
const commonError = { success: false, message: 'Что-то пошло не так' };
|
|
|
|
|
2024-12-07 23:40:22 +03:00
|
|
|
const sleep =
|
|
|
|
(duration = 1000) =>
|
2024-12-08 11:00:43 +03:00
|
|
|
(req, res, next) =>
|
|
|
|
setTimeout(next, duration);
|
2024-12-01 12:17:04 +03:00
|
|
|
|
|
|
|
router.use(sleep());
|
2024-12-01 11:51:52 +03:00
|
|
|
|
|
|
|
router.get('/arm/masters', (req, res) => {
|
|
|
|
res
|
2024-12-01 12:17:04 +03:00
|
|
|
.status(/error/.test(STUBS.masters) ? 500 : 200)
|
2024-12-01 11:51:52 +03:00
|
|
|
.send(
|
2024-12-01 12:17:04 +03:00
|
|
|
/^error$/.test(STUBS.masters)
|
2024-12-01 11:51:52 +03:00
|
|
|
? commonError
|
2024-12-01 12:17:04 +03:00
|
|
|
: require(`../json/arm-masters/${STUBS.masters}.json`),
|
2024-12-01 11:51:52 +03:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2024-12-14 22:27:07 +03:00
|
|
|
router.post('/arm/orders', (req, res) => {
|
2024-12-01 11:51:52 +03:00
|
|
|
res
|
2024-12-01 12:17:04 +03:00
|
|
|
.status(/error/.test(STUBS.orders) ? 500 : 200)
|
2024-12-01 11:51:52 +03:00
|
|
|
.send(
|
2024-12-01 12:17:04 +03:00
|
|
|
/^error$/.test(STUBS.orders)
|
2024-12-01 11:51:52 +03:00
|
|
|
? commonError
|
2024-12-01 12:17:04 +03:00
|
|
|
: require(`../json/arm-orders/${STUBS.orders}.json`),
|
2024-12-01 11:51:52 +03:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2024-12-22 11:15:50 +03:00
|
|
|
router.get('/order/:orderId', ({ params }, res) => {
|
|
|
|
const { orderId } = params;
|
|
|
|
const stubName = `${orderId}-${STUBS.orderView}`;
|
|
|
|
|
|
|
|
res
|
|
|
|
.status(/error/.test(stubName) ? 500 : 200)
|
|
|
|
.send(
|
|
|
|
/^error$/.test(stubName)
|
|
|
|
? commonError
|
|
|
|
: require(`../json/landing-order-view/${stubName}.json`),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2024-12-01 12:17:04 +03:00
|
|
|
router.use('/admin', require('./admin'));
|
2024-12-01 11:51:52 +03:00
|
|
|
|
2024-12-07 23:40:22 +03:00
|
|
|
module.exports = router;
|