mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 07:28:31 -05:00
feat: verifyStatusPage middleware
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user