feat(ops): health-fail alerts, optional DB backup, admin UX polish
Wire jobs-worker health probes to Discord/email alerts with cooldown, optional mysqldump, rate-limit /api/health, mark-all-read alerts, ConfirmDialog on destructive admin actions, and raise coverage floors. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
3bd712e744
commit
725e1cb338
16 files changed
+327
-32
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { NextResponse } from "next/server";
|
||||
import { env } from "@/env";
|
||||
import { apiJson } from "@/lib/api";
|
||||
import { db } from "@/lib/db";
|
||||
import { clientIp, rateLimit } from "@/lib/rate-limit";
|
||||
import { redis } from "@/lib/redis";
|
||||
import { rcon } from "@/lib/services/rcon";
|
||||
|
||||
@@ -11,9 +13,21 @@ export const dynamic = "force-dynamic";
|
||||
* Ops health probe: database reachability, Redis (when configured), emulator
|
||||
* RCON, SMTP (when configured), and runtime info. Returns HTTP 200 always
|
||||
* (read the `status`/`database` fields), so it's safe for uptime monitors that
|
||||
* only care about reachability.
|
||||
* only care about reachability. Rate-limited per client IP.
|
||||
*/
|
||||
export async function GET() {
|
||||
const ip = await clientIp();
|
||||
const limit = await rateLimit(`health:${ip}`, 60, 60_000);
|
||||
if (!limit.ok) {
|
||||
return NextResponse.json(
|
||||
{ status: "rate_limited", retryAfter: limit.retryAfter },
|
||||
{
|
||||
status: 429,
|
||||
headers: { "Retry-After": String(limit.retryAfter) },
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const database = await db
|
||||
.execute(sql`SELECT 1`)
|
||||
.then(() => true)
|
||||
|
||||
Reference in new issue
Block a user