chore: type name

This commit is contained in:
kuusei 2024-07-27 12:14:59 +08:00
parent 32307cdd1d
commit 38b794fc4f
No known key found for this signature in database
2 changed files with 3 additions and 12 deletions

View File

@ -1,5 +1,5 @@
import { NezhaAPI, NezhaAPISafe } from "@/app/types/nezha-api";
import { NezhaAPI, ServerApi } from "@/app/types/nezha-api";
import { MakeOptional } from "@/app/types/utils";
import { NextResponse } from "next/server";
@ -25,22 +25,13 @@ export async function GET(_: Request) {
}
});
const nezhaData = (await response.json()).result as NezhaAPI[];
const data: {
live_servers: number;
offline_servers: number;
total_bandwidth: number;
result: NezhaAPISafe[]
} = {
const data: ServerApi = {
live_servers: 0,
offline_servers: 0,
total_bandwidth: 0,
result: []
}
data.live_servers = 0;
data.offline_servers = 0;
data.total_bandwidth = 0;
data.result = nezhaData.map((element: MakeOptional<NezhaAPI, "ipv4" | "ipv6" | "valid_ip">) => {
if (element.status.Uptime !== 0) {
data.live_servers += 1;

View File

@ -1,4 +1,4 @@
export type serverApi = {
export type ServerApi = {
live_servers: number;
offline_servers: number;
total_bandwidth: number;