forked from bro-students/multy-stub
27 lines
566 B
JavaScript
27 lines
566 B
JavaScript
|
const express = require("express");
|
||
|
const router = express.Router()
|
||
|
|
||
|
const waitMiddleware = (req, res, next) => {
|
||
|
setTimeout(() => {
|
||
|
next()
|
||
|
}, 3000)
|
||
|
}
|
||
|
|
||
|
const listActivated = true
|
||
|
router.get('/list', waitMiddleware, (req, res) => {
|
||
|
req.user
|
||
|
|
||
|
if (listActivated) {
|
||
|
res.status(200).send(require('./news.json'))
|
||
|
} else {
|
||
|
res.status(500).send()
|
||
|
}
|
||
|
})
|
||
|
|
||
|
router.get('/list-activate-toggle', (req, res) => {
|
||
|
listActivated = !listActivated
|
||
|
res.send(listActivated ? 'Activated' : 'Deactivated')
|
||
|
})
|
||
|
|
||
|
module.exports = router
|