feat: verifyStatusPage middleware

This commit is contained in:
Br0wnHammer
2026-02-20 00:30:06 +05:30
parent dae2709d31
commit b87fd5438e
@@ -0,0 +1,18 @@
import { NextFunction, Request, Response } from "express";
import { IStatusPagesRepository } from "@/repositories/index.js";
export const createVerifyStatusPageAccess = (statusPagesRepository: IStatusPagesRepository) => {
return async (req: Request, res: Response, next: NextFunction) => {
try {
const url = req.params.url;
const statusPage = await statusPagesRepository.findByUrl(url);
if (statusPage.isPublished) {
next(); // Published — proceed to controller (no JWT)
} else {
next("route"); // Unpublished — skip to next route (which has verifyJWT)
}
} catch (error) {
next(error);
}
};
};