fix: apply middlewares before the controller definition
This commit is contained in:
parent
1d76e18d38
commit
45e7e88b09
1 changed files with 13 additions and 15 deletions
|
|
@ -58,21 +58,19 @@ const app = new Hono()
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.get("healthcheck", (c) => c.json({ status: "ok" }))
|
.get("healthcheck", (c) => c.json({ status: "ok" }))
|
||||||
.route(
|
.route("/api/v1/auth", authController.basePath("/api/v1"))
|
||||||
"/api/v1/auth",
|
.use("/api/v1/volumes/*", requireAuth)
|
||||||
authController.use(
|
.use("/api/v1/repositories/*", requireAuth)
|
||||||
rateLimit({
|
.use("/api/v1/backups/*", requireAuth)
|
||||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
.use("/api/v1/notifications/*", requireAuth)
|
||||||
limit: 5, // stricter limit for auth endpoints to prevent brute force
|
.use("/api/v1/system/*", requireAuth)
|
||||||
}),
|
.use("/api/v1/events/*", requireAuth)
|
||||||
).basePath("/api/v1"),
|
.route("/api/v1/volumes", volumeController)
|
||||||
)
|
.route("/api/v1/repositories", repositoriesController)
|
||||||
.route("/api/v1/volumes", volumeController.use(requireAuth))
|
.route("/api/v1/backups", backupScheduleController)
|
||||||
.route("/api/v1/repositories", repositoriesController.use(requireAuth))
|
.route("/api/v1/notifications", notificationsController)
|
||||||
.route("/api/v1/backups", backupScheduleController.use(requireAuth))
|
.route("/api/v1/system", systemController)
|
||||||
.route("/api/v1/notifications", notificationsController.use(requireAuth))
|
.route("/api/v1/events", eventsController);
|
||||||
.route("/api/v1/system", systemController.use(requireAuth))
|
|
||||||
.route("/api/v1/events", eventsController.use(requireAuth));
|
|
||||||
|
|
||||||
// API documentation endpoints require authentication
|
// API documentation endpoints require authentication
|
||||||
app.get("/api/v1/openapi.json", requireAuth, generalDescriptor(app));
|
app.get("/api/v1/openapi.json", requireAuth, generalDescriptor(app));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue