quetre/routes/apiRoutes.js
zyachel d8515d5edd refactor: DRY some code related to answers
as there are two routes for answers(/unanswered/:slug and /:slug), and both contained similar code, reduced controllers(for the routes) in api as well as in views to just one controller handling the logic to fetch data.
2022-05-21 12:58:44 +05:30

13 lines
418 B
JavaScript

import express from 'express';
import { about, unimplemented, answers } from '../controllers/apiController.js';
const apiRouter = express.Router();
apiRouter.get('/', about);
apiRouter.get('/search', unimplemented);
apiRouter.get('/profile/:name', unimplemented);
apiRouter.get('/topic/:name', unimplemented);
apiRouter.get('/unanswered/:slug', answers);
apiRouter.get('/:slug', answers);
export default apiRouter;