22 lines
734 B
TypeScript
22 lines
734 B
TypeScript
import { env } from "@/env.mjs";
|
|
import { getUserRecords } from "@/lib/dto/cloudflare-dns-record";
|
|
import { checkUserStatus } from "@/lib/dto/user";
|
|
import { getCurrentUser } from "@/lib/session";
|
|
|
|
export async function GET(req: Request) {
|
|
try {
|
|
const user = checkUserStatus(await getCurrentUser());
|
|
if (user instanceof Response) return user;
|
|
// const { CLOUDFLARE_ZONE_ID, CLOUDFLARE_API_KEY, CLOUDFLARE_EMAIL } = env;
|
|
|
|
const user_records = await getUserRecords(user.id, 1);
|
|
|
|
return Response.json(user_records);
|
|
} catch (error) {
|
|
return Response.json(error?.statusText || error, {
|
|
status: error.status || 500,
|
|
statusText: error.statusText || "Server error",
|
|
});
|
|
}
|
|
}
|