forked from bro-students/multy-stub
example
This commit is contained in:
parent
73ececf944
commit
9fd69a2d2d
@ -58,6 +58,7 @@ app.use('/zoom-bar', require('./routers/zoom-bar'))
|
||||
app.use('/basket', require('./routers/basket'))
|
||||
app.use('/easy-project', require('./routers/easy-project'))
|
||||
app.use('/sugarbun', require('./routers/sugarbun'))
|
||||
app.use('/epja-2023-2', require('./routers/epja-2023-2'))
|
||||
require('./routers/hub-video')
|
||||
|
||||
app.use(require('./error'))
|
||||
|
26
server/routers/epja-2023-2/example/index.js
Normal file
26
server/routers/epja-2023-2/example/index.js
Normal file
@ -0,0 +1,26 @@
|
||||
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
|
25
server/routers/epja-2023-2/example/news.json
Normal file
25
server/routers/epja-2023-2/example/news.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"ok": true,
|
||||
"data": [
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Some name 1",
|
||||
"description": "Some long long long long description"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "Some name 2",
|
||||
"description": "Some long long long long description"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"name": "Some name 3",
|
||||
"description": "Some long long long long description"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"name": "Some name 4",
|
||||
"description": "Some long long long long description"
|
||||
}
|
||||
]
|
||||
}
|
7
server/routers/epja-2023-2/index.js
Normal file
7
server/routers/epja-2023-2/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
|
||||
router.use('/example', require('./example/index'))
|
||||
|
||||
module.exports = router
|
Loading…
Reference in New Issue
Block a user