CVE Patch + Post stream rubgram + tl improvements
- Switch to using generated columns for rubgram's paid - Few text changes - Isolate badges to their type - Use Redis to cache health checks - Remove confusing logging and add actionLog stdout logging - Blacklist RSC/prefetch related requests from nginx logging - Fix nginx upload size limit
This commit is contained in:
+44
-20
@@ -2,29 +2,53 @@ import { sql } from "drizzle-orm";
|
||||
import { db } from "@/lib/db";
|
||||
import { redis } from "@/lib/db/redis";
|
||||
|
||||
export const revalidate = 900;
|
||||
|
||||
export async function GET() {
|
||||
const database = await db
|
||||
.execute(sql<boolean>`select true`)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
const red = await redis
|
||||
.ping()
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
const enka = await fetch("https://enka.network/api/uid/888888888/?info", {
|
||||
cache: "force-cache",
|
||||
headers: { "User-Agent": "Buzz Event Platform(Health Checker)" },
|
||||
signal: AbortSignal.timeout(5000),
|
||||
})
|
||||
.then((r) => r.ok)
|
||||
.catch(() => false);
|
||||
const amber = await fetch("https://gi.yatta.moe/api/v2/en/avatar", {
|
||||
cache: "force-cache",
|
||||
signal: AbortSignal.timeout(5000),
|
||||
})
|
||||
.then((r) => r.ok)
|
||||
.catch(() => false);
|
||||
return Response.json({ database, red, enka, amber });
|
||||
const res = Object.fromEntries(
|
||||
await Promise.all(
|
||||
Object.entries(checks).map(
|
||||
async ([k, v]) =>
|
||||
[
|
||||
k,
|
||||
red
|
||||
? (await redis.exists(`health:${k}`))
|
||||
? (await redis.get(`health:${k}`)) === "ok"
|
||||
: await v().then(async (v) => {
|
||||
if (v) await redis.setex(`health:${k}`, 900, "ok");
|
||||
return v;
|
||||
})
|
||||
: await v(),
|
||||
] as const,
|
||||
),
|
||||
),
|
||||
);
|
||||
return Response.json({ red, ...res });
|
||||
}
|
||||
|
||||
const checks = {
|
||||
async database() {
|
||||
return await db
|
||||
.execute(sql<boolean>`select true`)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
},
|
||||
async enka() {
|
||||
return await fetch("https://enka.network/api/uid/888888888/?info", {
|
||||
headers: { "User-Agent": "Buzz, https://buzz.sudloh.com/api/health" },
|
||||
signal: AbortSignal.timeout(5000),
|
||||
})
|
||||
.then((r) => r.ok)
|
||||
.catch(() => false);
|
||||
},
|
||||
async amber() {
|
||||
return await fetch("https://gi.yatta.moe/api/v2/en/avatar", {
|
||||
headers: { "User-Agent": "Buzz, https://buzz.sudloh.com/api/health" },
|
||||
signal: AbortSignal.timeout(5000),
|
||||
})
|
||||
.then((r) => r.ok)
|
||||
.catch(() => false);
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -18,8 +18,6 @@ export async function GET(
|
||||
if (!sub) notFound();
|
||||
if (!sub.slip) notFound();
|
||||
|
||||
console.log(sub.slip.length);
|
||||
|
||||
return new Response(new Uint8Array(sub.slip), {
|
||||
headers: {
|
||||
"Content-Type": "image/jpeg",
|
||||
|
||||
Reference in New Issue
Block a user