Merge pull request '[feat] add chgk api' (#71) from sber_web into master

Reviewed-on: #71
This commit is contained in:
nekitboy1998 2025-01-31 13:43:18 +03:00
commit c000106ec8
4 changed files with 41 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}
});

View File

@ -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);
}
});