75 lines
2.0 KiB
TypeScript
Executable File
75 lines
2.0 KiB
TypeScript
Executable File
import { GoogleGenAI } from "@google/genai";
|
|
import { env } from "bun";
|
|
import { sql } from "drizzle-orm";
|
|
import { db } from "@/lib/db";
|
|
import { redis as redisShared } from "@/lib/db/redis";
|
|
import { createHealthHandler } from "./handler";
|
|
|
|
const { DISCORD_BOT_TOKEN, GEMINI_TTS_API_KEY } = env as Record<string, string>;
|
|
|
|
const redis = redisShared!;
|
|
|
|
export const revalidate = 60;
|
|
|
|
const checks = {
|
|
async database() {
|
|
return await db
|
|
.execute(sql<boolean>`select true`)
|
|
.then(() => true)
|
|
.catch(() => false);
|
|
},
|
|
async enka() {
|
|
return fetch("https://enka.network/api/uid/888888888/?info", {
|
|
headers: { "User-Agent": "Buzz, https://buzz.sudloh.com/api/health" },
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
},
|
|
async amber() {
|
|
return fetch("https://gi.yatta.moe/api/v2/en/avatar", {
|
|
headers: { "User-Agent": "Buzz, https://buzz.sudloh.com/api/health" },
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
},
|
|
async yt() {
|
|
return fetch("https://buzz.sudloh.com/api/live?last=true", {
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
},
|
|
async card() {
|
|
return fetch("https://api.astrxl.dev/v1/card/genshin/stats", {
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
},
|
|
async slip() {
|
|
return fetch("https://api.slipok.com/", {
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
},
|
|
async tts() {
|
|
const apiKey = GEMINI_TTS_API_KEY?.split(",").find(Boolean);
|
|
if (!apiKey) return false;
|
|
const client = new GoogleGenAI({
|
|
apiKey,
|
|
});
|
|
return client.models
|
|
.list()
|
|
.then(() => true)
|
|
.catch(() => false);
|
|
},
|
|
async tmn() {
|
|
return fetch("https://api.sastify.xyz/health", {
|
|
signal: AbortSignal.timeout(5000),
|
|
});
|
|
},
|
|
async discord() {
|
|
return fetch("https://discord.com/api/v10/users/@me", {
|
|
signal: AbortSignal.timeout(5000),
|
|
headers: {
|
|
Authorization: `Bot ${DISCORD_BOT_TOKEN}`,
|
|
},
|
|
});
|
|
},
|
|
} satisfies Record<string, () => Promise<Response | boolean>>;
|
|
|
|
export const GET = createHealthHandler({ redis, checks });
|