Refactor routers to be class based
This commit is contained in:
1 parent
cc40bd6006
commit
0861595d39
8 files changed
+255
-140
No files matched your search
@@ -1,11 +1,22 @@
|
||||
import express from "express";
|
||||
import { verifyJWT } from "../middleware/verifyJWT.js";
|
||||
import {
|
||||
createStatusPage,
|
||||
getStatusPageByUrl,
|
||||
} from "../controllers/statusPageController.js";
|
||||
const router = express.Router();
|
||||
import { Router } from "express";
|
||||
|
||||
router.get("/:url", getStatusPageByUrl);
|
||||
router.post("/:url", verifyJWT, createStatusPage);
|
||||
export default router;
|
||||
import { verifyJWT } from "../middleware/verifyJWT.js";
|
||||
|
||||
class StatusPageRoutes {
|
||||
constructor(statusPageController) {
|
||||
this.router = Router();
|
||||
this.statusPageController = statusPageController;
|
||||
this.initRoutes();
|
||||
}
|
||||
|
||||
initRoutes() {
|
||||
this.router.get("/:url", this.statusPageController.getStatusPageByUrl);
|
||||
this.router.post("/:url", verifyJWT, this.statusPageController.createStatusPage);
|
||||
}
|
||||
|
||||
getRouter() {
|
||||
return this.router;
|
||||
}
|
||||
}
|
||||
|
||||
export default StatusPageRoutes;
|
||||
Reference in new issue
Block a user