dry-wash-pl/stubs/api/index.js
ilnaz e4b9aefe57
All checks were successful
it-academy/dry-wash-pl/pipeline/pr-main This commit looks good
fix: add spaces
2024-12-08 11:00:43 +03:00

39 lines
938 B
JavaScript

/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-require-imports */
const router = require('express').Router();
const STUBS = require('./admin').STUBS;
const commonError = { success: false, message: 'Что-то пошло не так' };
const sleep =
(duration = 1000) =>
(req, res, next) =>
setTimeout(next, duration);
router.use(sleep());
router.get('/arm/masters', (req, res) => {
res
.status(/error/.test(STUBS.masters) ? 500 : 200)
.send(
/^error$/.test(STUBS.masters)
? commonError
: require(`../json/arm-masters/${STUBS.masters}.json`),
);
});
router.get('/arm/orders', (req, res) => {
res
.status(/error/.test(STUBS.orders) ? 500 : 200)
.send(
/^error$/.test(STUBS.orders)
? commonError
: require(`../json/arm-orders/${STUBS.orders}.json`),
);
});
router.use('/admin', require('./admin'));
module.exports = router;