Форум по Javascript
Anonymous
Возникла проблема с моими экспресс-маршрутами
Сообщение
Anonymous » 27 янв 2025, 02:16
Я столкнулся с проблемой с моими экспресс-маршрутами, когда доступ к конечной точке /notification/group неправильно запускает getNotificationByIdController вместо предполагаемого getNotificationGroupsController.
Код: Выделить всё
import express from "express";
import { isAdmin } from "../middlewares/auth.middleware";
import notificationControllers from "../controllers/notification.controller";
const adminRouter = express.Router();
// Routes for individual notifications
adminRouter
.route("/notification/:notificationId")
.put(isAdmin, notificationControllers.updateNotificationController)
.delete(isAdmin, notificationControllers.deleteNotificationController)
.get(isAdmin, notificationControllers.getNotificationByIdController);
// Routes for notification groups
adminRouter
.route("/notification/group")
.post(isAdmin, notificationControllers.createNotificationGroupController)
.get(isAdmin, notificationControllers.getNotificationGroupsController);
export default adminRouter;
GET /notification/group должен вызывать getNotificationGroupsController для получения всех групп уведомлений.
Подробнее здесь:
https://stackoverflow.com/questions/793 ... ess-routes
1737933379
Anonymous
Я столкнулся с проблемой с моими экспресс-маршрутами, когда доступ к конечной точке /notification/group неправильно запускает getNotificationByIdController вместо предполагаемого getNotificationGroupsController. [code]import express from "express"; import { isAdmin } from "../middlewares/auth.middleware"; import notificationControllers from "../controllers/notification.controller"; const adminRouter = express.Router(); // Routes for individual notifications adminRouter .route("/notification/:notificationId") .put(isAdmin, notificationControllers.updateNotificationController) .delete(isAdmin, notificationControllers.deleteNotificationController) .get(isAdmin, notificationControllers.getNotificationByIdController); // Routes for notification groups adminRouter .route("/notification/group") .post(isAdmin, notificationControllers.createNotificationGroupController) .get(isAdmin, notificationControllers.getNotificationGroupsController); export default adminRouter; [/code] GET /notification/group должен вызывать getNotificationGroupsController для получения всех групп уведомлений. Подробнее здесь: [url]https://stackoverflow.com/questions/79389458/encountering-an-issue-with-my-express-routes[/url]