Added api route to retrieve bot commands list.

This commit is contained in:
2026-01-26 18:15:50 -05:00
parent d15eab2421
commit 369b3bf133
2 changed files with 38 additions and 1 deletions

37
src/app/api/bot/route.ts Normal file
View File

@@ -0,0 +1,37 @@
import { headers } from "next/headers";
import botCommands from "@/data/botCommands";
const environment = process.env.NODE_ENV || "development";
const isValidApiKey = (apiKey: string): boolean => {
const envApiKey =
process.env.API_TOKEN || process.env.NEXT_PUBLIC_API_TOKEN || "";
return apiKey === envApiKey;
};
export async function GET(/*request: Request*/) {
const headersList = await headers();
const apiKey = headersList.get("x-api-key");
if (environment === "production") {
if (!apiKey || apiKey == null) {
return new Response("No API Key provided", {
status: 401,
headers: headersList
});
}
if (apiKey !== null && !(await isValidApiKey(apiKey))) {
return new Response("Invalid API Key", {
status: 403,
headers: headersList
});
}
}
return Response.json(botCommands, {
status: 200,
headers: headersList
});
}

View File

@@ -40,7 +40,7 @@ const LineChartComponent = ({
tickLine={false} tickLine={false}
tickMargin={10} tickMargin={10}
stroke={chart.color("border")} stroke={chart.color("border")}
// label={{ value: label, position: "left", angle: -90 }} // label={{ value: label, position: "left", angle: -90 }}
/> />
<Tooltip <Tooltip
animationDuration={100} animationDuration={100}