mirror of
https://github.com/PretendoNetwork/mario_kart_8_website.git
synced 2024-06-01 11:38:03 -04:00
32 lines
1,022 B
TypeScript
32 lines
1,022 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { cookies } from "next/headers";
|
|
import { JWTTokenPayload, getMK8TokenEx } from "@/helpers/types/JWTTokenPayload";
|
|
import { amkj_grpc_client } from "@/helpers/grpc";
|
|
import { Metadata } from "nice-grpc";
|
|
import app_config from "@/app.config";
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const cookieStore = cookies();
|
|
const mk8_token = cookieStore.get("mk8_token");
|
|
if (!mk8_token) {
|
|
return new NextResponse("{}", { status: 401 });
|
|
}
|
|
|
|
const token: JWTTokenPayload | null = await getMK8TokenEx(mk8_token.value);
|
|
if (!token) {
|
|
return new NextResponse("{}", { status: 401 });
|
|
}
|
|
|
|
const res = await amkj_grpc_client.endMaintenance({}, {
|
|
metadata: Metadata({
|
|
"X-API-Key": app_config.grpc_api_key
|
|
})
|
|
});
|
|
|
|
return NextResponse.json(res);
|
|
|
|
} catch (err) {
|
|
return new NextResponse("{}", { status: 500 });
|
|
}
|
|
} |