journal.pl/stubs/api/index.js
primakov 97e940b873
Some checks failed
gitea-bro-js/journal.pl/pipeline/head There was a failure building this commit
Форма создания лекции (#1)
2024-03-28 18:59:16 +03:00

49 lines
1.3 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'))
})
module.exports = router