From da84344a63ba6112a62ff85a4be9fcda8362ca02 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 31 Jan 2025 13:35:11 +0300 Subject: [PATCH] [feat] add chgk api --- server/routers/kfu-m-24-1/index.js | 1 + server/routers/kfu-m-24-1/sber_web/index.js | 8 ++++++++ .../kfu-m-24-1/sber_web/question/index.js | 16 ++++++++++++++++ .../kfu-m-24-1/sber_web/questions/index.js | 16 ++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 server/routers/kfu-m-24-1/sber_web/index.js create mode 100644 server/routers/kfu-m-24-1/sber_web/question/index.js create mode 100644 server/routers/kfu-m-24-1/sber_web/questions/index.js diff --git a/server/routers/kfu-m-24-1/index.js b/server/routers/kfu-m-24-1/index.js index b46739b..609da3e 100644 --- a/server/routers/kfu-m-24-1/index.js +++ b/server/routers/kfu-m-24-1/index.js @@ -3,6 +3,7 @@ const router = Router() router.use('/eng-it-lean', require('./eng-it-lean/index')) router.use('/sberhubproject', require('./sberhubproject/index')) +router.use('/sber_web', require('./sber_web/index')) module.exports = router diff --git a/server/routers/kfu-m-24-1/sber_web/index.js b/server/routers/kfu-m-24-1/sber_web/index.js new file mode 100644 index 0000000..c77018e --- /dev/null +++ b/server/routers/kfu-m-24-1/sber_web/index.js @@ -0,0 +1,8 @@ +const router = require('express').Router(); +const listRouter = require('./questions'); +const questionRouter = require('./question'); + +module.exports = router; + +router.use('/questions', listRouter); +router.use('/question', questionRouter); diff --git a/server/routers/kfu-m-24-1/sber_web/question/index.js b/server/routers/kfu-m-24-1/sber_web/question/index.js new file mode 100644 index 0000000..df47bfe --- /dev/null +++ b/server/routers/kfu-m-24-1/sber_web/question/index.js @@ -0,0 +1,16 @@ +const axios = require('axios'); +const router = require('express').Router(); + +module.exports = router; + +router.get('/:id', async (req, res) => { + const id = req.params.id; + const baseUrl = 'http://www.db.chgk.info'; + try { + const data = await axios.get(baseUrl + `/questions/${id}`); + res.send(data.data); + } + catch (e) { + res.send(undefined); + } +}); diff --git a/server/routers/kfu-m-24-1/sber_web/questions/index.js b/server/routers/kfu-m-24-1/sber_web/questions/index.js new file mode 100644 index 0000000..5192dbc --- /dev/null +++ b/server/routers/kfu-m-24-1/sber_web/questions/index.js @@ -0,0 +1,16 @@ +const axios = require('axios'); +const router = require('express').Router(); + +module.exports = router; + +router.get('/:page', async (req, res) => { + const page = req.params.page; + const baseUrl = 'http://www.db.chgk.info'; + try { + const data = await axios.get(baseUrl + `/questions?page=${page}&itemsPerPage=15`); + res.send(data.data); + } + catch (e) { + res.send(undefined); + } +});