Add ready endpoint

This commit is contained in:
Ajay
2024-04-16 01:13:56 -04:00
parent 07d4dde4f6
commit 2251ddc251
4 changed files with 18 additions and 0 deletions

13
src/routes/getReady.ts Normal file
View 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);
}
}