import { Card } from "@/app/components/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/app/components/ui/table"; import { generateEmbed } from "@/common/embed"; import { capitalizeFirstLetter } from "@/common/string-utils"; import { cn } from "@/common/utils"; import { getMojangEndpointStatus } from "mcutils-library"; import { CachedEndpointStatus } from "mcutils-library/dist/types/cache/cachedEndpointStatus"; import { Metadata } from "next"; import Link from "next/link"; /** * Force the page to be dynamic, so it will be regenerated on every request */ export const dynamic = "force-dynamic"; /** * Gets the color of the status * * @param status the status of the endpoint * @returns the color of the status */ function getColor(status: any): string { switch (status) { case "ONLINE": return "text-green-500"; case "DEGRADED": return "text-yellow-500"; case "OFFLINE": return "text-red-500"; default: return "text-gray-500"; } } /** * Formats the status * * @param status the status of the endpoint * @returns the formatted status */ function formatStatus(status: any): string { return capitalizeFirstLetter(status.toLowerCase()); } async function getData(): Promise { const status = await getMojangEndpointStatus(); return status; } export async function generateMetadata(): Promise { const { endpoints } = await getData(); let description = "The current status of Mojang Services"; description += Object.entries(endpoints) .map(([url, status]) => { return `**${url}**: ${formatStatus(status)}`; }) .join("\n"); return generateEmbed({ title: "Mojang Status", description: description, }); } export default async function Page(): Promise { const { endpoints } = await getData(); const endpointsSize = Object.entries(endpoints).length; return (

Mojang Status

The current status of Mojang Services

{endpointsSize === 0 &&

Unable to fetch endpoint statuses

} {endpointsSize > 0 && ( Service Status {Object.entries(endpoints).map(([url, status]) => { return ( {url} {formatStatus(status)} ); })}
)}
); }