diff --git a/app/api/users/[id]/.temp b/app/api/users/[id]/.temp deleted file mode 100644 index e69de29..0000000 diff --git a/app/api/users/login/route.ts b/app/api/users/login/route.ts index dbf2277..4270a0b 100644 --- a/app/api/users/login/route.ts +++ b/app/api/users/login/route.ts @@ -1,7 +1,7 @@ const BACKEND_URL = process.env.BACKEND_URL; export async function POST(request: Request) { - const response = await fetch(`${BACKEND_URL}/users/token`, request); + const response = await fetch(`${BACKEND_URL}/users/auth`, request); const data = await response.json(); diff --git a/app/api/users/user/id/[id]/route.ts b/app/api/users/user/id/[id]/route.ts new file mode 100644 index 0000000..80dea7a --- /dev/null +++ b/app/api/users/user/id/[id]/route.ts @@ -0,0 +1,19 @@ +const BACKEND_URL = process.env.BACKEND_URL; + +export async function GET( + _request: Request, + { params }: { params: Promise<{ id: string }> }, +) { + const { id } = await params; + const response = await fetch(`${BACKEND_URL}/users/user/id/${id}`); + + if (!response.ok) { + return new Response("Request failed in backend", { + status: response.status, + }); + } + + const data = await response.json(); + + return Response.json(data); +} diff --git a/app/api/users/user/route.ts b/app/api/users/user/route.ts new file mode 100644 index 0000000..9f0e902 --- /dev/null +++ b/app/api/users/user/route.ts @@ -0,0 +1,15 @@ +const BACKEND_URL = process.env.BACKEND_URL; + +export async function GET() { + const response = await fetch(`${BACKEND_URL}/users/user`); + + if (!response.ok) { + return new Response("Request failed in backend", { + status: response.status, + }); + } + + const data = await response.json(); + + return Response.json(data); +} diff --git a/app/api/users/user/username/[username]/route.ts b/app/api/users/user/username/[username]/route.ts new file mode 100644 index 0000000..640edbb --- /dev/null +++ b/app/api/users/user/username/[username]/route.ts @@ -0,0 +1,19 @@ +const BACKEND_URL = process.env.BACKEND_URL; + +export async function GET( + _request: Request, + { params }: { params: Promise<{ username: string }> }, +) { + const { username } = await params; + const response = await fetch(`${BACKEND_URL}/users/user/name/${username}`); + + if (!response.ok) { + return new Response("Request failed in backend", { + status: response.status, + }); + } + + const data = await response.json(); + + return Response.json(data); +}