mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-27 14:15:50 +02:00
30 lines
809 B
TypeScript
30 lines
809 B
TypeScript
|
import { Request, Response, NextFunction } from "express";
|
||
|
import createHttpError from "http-errors";
|
||
|
import HttpCode from "@server/types/HttpCode";
|
||
|
import config from "@server/lib/config";
|
||
|
|
||
|
export async function verifyClientsEnabled(
|
||
|
req: Request,
|
||
|
res: Response,
|
||
|
next: NextFunction
|
||
|
) {
|
||
|
try {
|
||
|
if (!config.getRawConfig().flags?.enable_redis) {
|
||
|
return next(
|
||
|
createHttpError(
|
||
|
HttpCode.NOT_IMPLEMENTED,
|
||
|
"Clients are not enabled on this server."
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
return next();
|
||
|
} catch (error) {
|
||
|
return next(
|
||
|
createHttpError(
|
||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||
|
"Failed to check if clients are enabled"
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
}
|