journal.pl/stubs/api/index.js
primakov a32e55807b
Some checks failed
platform/bro/pipeline/pr-master This commit looks good
platform/bro/pipeline/head This commit looks good
platform/gitea-bro-js/journal.pl/pipeline/head There was a failure building this commit
platform/bro-js/journal.pl/pipeline/head This commit looks good
(#16) Редактирование лекции
2024-04-02 16:17:24 +03:00

57 lines
1.5 KiB
JavaScript

const router = require('express').Router()
const fs = require('node:fs')
const path = require('node:path')
const timer =
(time = 1000) =>
(_req, _res, next) =>
setTimeout(next, time)
router.use(timer())
router.get('/course/list', (req, res) => {
res.send(require('../mocks/courses/list/success.json'))
})
router.get('/course/students/:courseId', (req, res) => {
res.send(require('../mocks/courses/all-students/success.json'))
})
router.post('/course', (req, res) => {
res.send(require('../mocks/courses/create/success.json'))
})
router.get('/lesson/list/:courseId', (req, res) => {
res.send(require('../mocks/lessons/list/success.json'))
})
router.post('/lesson', (req, res) => {
res.send(require('../mocks/lessons/create/success.json'))
})
router.post('/lesson/access-code', (req, res) => {
const answer = fs.readFileSync(
path.resolve(__dirname, '../mocks/lessons/access-code/create/success.json'),
)
// res.send(require('../mocks/lessons/access-code/create/success.json'))
res.send(answer)
})
router.get('/lesson/access-code/:accessCode', (req, res) => {
res.status(400).send(require('../mocks/lessons/access-code/get/error.json'))
})
router.get('/lesson/:lessonId', (req, res) => {
res.send(require('../mocks/lessons/byid/success.json'))
})
router.delete('/lesson/:lessonId', (req, res) => {
res.send({ success: true, body: { ok: true }})
})
router.put('/lesson/:lessonId', (req, res) => {
res.send({ success: true, body: req.body })
})
module.exports = router