mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-26 01:18:40 +03:00
Add ready endpoint
This commit is contained in:
13
src/routes/getReady.ts
Normal file
13
src/routes/getReady.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Request, Response } from "express";
|
||||
import { Server } from "http";
|
||||
import { config } from "../config";
|
||||
|
||||
export async function getReady(req: Request, res: Response, server: Server): Promise<Response> {
|
||||
const connections = await new Promise((resolve) => server.getConnections((_, count) => resolve(count))) as number;
|
||||
|
||||
if (!connections || connections < config.maxConnections) {
|
||||
return res.sendStatus(200);
|
||||
} else {
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user