/* eslint-disable no-undef */ /* eslint-disable @typescript-eslint/no-require-imports */ const router = require('express').Router(); const commonError = { success: false, message: 'Что то пошло не так' }; const stubs = { masters: 'success', orders: 'success' }; 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.get('/admin', (req, res) => { res.send(`
Мастера
Заказы
`); }); router.get('/admin/set/:name/:value', (req, res) => { const { name, value } = req.params; stubs[name] = value; res.send('ok'); }); module.exports = router;