"use server"; import { NextResponse } from "next/server"; import { getUserById } from "~/server/functions"; export const GET = async (request: Request) => { try { const url = new URL(request.url); const apiKey = url.searchParams.get("apiKey"); if (apiKey !== process.env.API_KEY) { console.log("Invalid API Key"); return NextResponse.json({ message: "Invalid API Key" }, { status: 401 }); } else { const userId = url.searchParams.get("userId") ?? "2"; const user = await getUserById(parseInt(userId)); return NextResponse.json(user); } } catch (error) { console.error(error); return NextResponse.json({ message: "Error" }, { status: 500 }); } };