initial admin

This commit is contained in:
Dreamgineer
2025-10-15 01:03:31 -04:00 Unverified
parent ba6143f63b
commit fc97ebc35f
99 changed files with 2351 additions and 1408 deletions
+8 -5
View File
@@ -1,9 +1,12 @@
export const revalidate = 3600;
export async function GET() {
return new Response(await fetch("https://gi.yatta.moe/api/v2/en/avatar").then(e => e.text()), {
headers: {
"Content-Type": "application/json"
}
});
return new Response(
await fetch("https://gi.yatta.moe/api/v2/en/avatar").then((e) => e.text()),
{
headers: {
"Content-Type": "application/json",
},
},
);
}
+10 -5
View File
@@ -1,9 +1,14 @@
export const revalidate = 3600;
export async function GET() {
return new Response(await fetch("https://gi.yatta.moe/api/v2/static/changelog").then(e => e.text()), {
headers: {
"Content-Type": "application/json"
}
});
return new Response(
await fetch("https://gi.yatta.moe/api/v2/static/changelog").then((e) =>
e.text(),
),
{
headers: {
"Content-Type": "application/json",
},
},
);
}
+23
View File
@@ -0,0 +1,23 @@
import { sql } from "drizzle-orm";
import { db } from "@/lib/db";
export const revalidate = 900;
export async function GET() {
const database = await db
.execute(sql<boolean>`select true`)
.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)" },
})
.then((r) => r.ok)
.catch(() => false);
const amber = await fetch("https://gi.yatta.moe/api/v2/en/avatar", {
cache: "force-cache",
})
.then((r) => r.ok)
.catch(() => false);
return Response.json({ database, enka, amber });
}
+47 -45
View File
@@ -2,52 +2,54 @@ import { NextResponse } from "next/server";
export const revalidate = 900;
export type YoutubeLiveInfo = {
url: string;
thumbnails: {
url: string;
width: number;
height: number;
}
} | "none";
export type YoutubeLiveInfo =
| {
url: string;
thumbnails: {
url: string;
width: number;
height: number;
};
}
| "none";
type APISearchResource = {
"kind": "youtube#searchResult",
"etag": string,
"id": {
"kind": string,
"videoId": string,
"channelId": string,
"playlistId": string
},
"snippet": {
"publishedAt": string,
"channelId": string,
"title": string,
"description": string,
"thumbnails": {
kind: "youtube#searchResult";
etag: string;
id: {
kind: string;
videoId: string;
channelId: string;
playlistId: string;
};
snippet: {
publishedAt: string;
channelId: string;
title: string;
description: string;
thumbnails: {
[key: string]: {
"url": string,
"width": number,
"height": number
}
},
"channelTitle": string,
"liveBroadcastContent": string
}
url: string;
width: number;
height: number;
};
};
channelTitle: string;
liveBroadcastContent: string;
};
};
type APISearchResponse = {
"kind": "youtube#searchListResponse",
"etag": string,
"nextPageToken": string,
"prevPageToken": string,
"regionCode": string,
"pageInfo": {
"totalResults": number,
"resultsPerPage": number
},
"items": APISearchResource[],
kind: "youtube#searchListResponse";
etag: string;
nextPageToken: string;
prevPageToken: string;
regionCode: string;
pageInfo: {
totalResults: number;
resultsPerPage: number;
};
items: APISearchResource[];
};
export async function GET() {
@@ -61,18 +63,18 @@ export async function GET() {
revalidate: 900, // refresh every 15 minutes
},
cache: "force-cache",
}
},
);
if (!response.ok)
throw new Error(`YouTube API error: ${response.statusText}`);
const data: APISearchResponse = await response.json();
if (data.items.length <= 0)
return NextResponse.json<YoutubeLiveInfo>("none");
if (data.items.length <= 0) return NextResponse.json<YoutubeLiveInfo>("none");
const live = data.items[0];
return NextResponse.json<YoutubeLiveInfo>({
url: `https://www.youtube.com/watch?v=${live.id.videoId}`,
thumbnails: live.snippet.thumbnails[Object.keys(live.snippet.thumbnails)[0]]
thumbnails:
live.snippet.thumbnails[Object.keys(live.snippet.thumbnails)[0]],
});
}
}