Add new user paths, update user routing to new (WORKING!) user auth version of BE
This commit is contained in:
parent
f5466faa70
commit
d3064fd764
5 changed files with 54 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
const BACKEND_URL = process.env.BACKEND_URL;
|
const BACKEND_URL = process.env.BACKEND_URL;
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
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();
|
const data = await response.json();
|
||||||
|
|
||||||
|
|
|
||||||
19
app/api/users/user/id/[id]/route.ts
Normal file
19
app/api/users/user/id/[id]/route.ts
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
15
app/api/users/user/route.ts
Normal file
15
app/api/users/user/route.ts
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
19
app/api/users/user/username/[username]/route.ts
Normal file
19
app/api/users/user/username/[username]/route.ts
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue