Skip to content

Commit

Permalink
ar(fix) bots shield
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloreale committed Aug 27, 2024
1 parent 00a8308 commit a1aab14
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/app/api/v1/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,39 @@ export async function POST(request: CombineRequest) {
}
}

const cookies = request?.cookies?.toString() || request?.headers?.get('cookies');
const session = await GetSession({ cookies: cookies || '' });
const user = session?.user;
try {
const cookies = request?.cookies?.toString() || request?.headers?.get('cookies');
const session = await GetSession({ cookies: cookies || '' });
const user = session?.user;

const body = await request?.json();
const action = body?.action;
// const listings = body?.action;
const body = await request?.json();
const action = body?.action;

if (!!user && !!action) {
const payload = { data: {} };
try {
if (!!user && !!action) {
const payload = { data: {} };
if (action === 'get-own-abilities') {
payload.data = await GetPrivateAbilities({ filters: ['user'], user });
} else if (action === 'get-own-services') {
payload.data = await GetPrivateServices({ filters: ['user'], user });
} else {
throw new Error('Code 000/1: No specified action');
}
} catch (e) {
return NextResponse.json(generateErrorResponse(e, 400), { status: 400 });
return NextResponse.json(
{
ok: true,
status: 200,
data: payload.data,
},
{
status: 200,
},
);
}

return NextResponse.json(
{
ok: true,
status: 200,
data: payload.data,
},
{
status: 200,
},
);
return NextResponse.json(generateErrorResponse({ message: 'Code 000: Malformed request' }, 400), { status: 400 });
} catch (e) {
return NextResponse.json(generateErrorResponse(e, 400), { status: 400 });
}

return NextResponse.json(generateErrorResponse({ message: 'Code 000: Malformed request' }, 400), { status: 400 });
}

export async function PATCH(request: CombineRequest) {
Expand Down

0 comments on commit a1aab14

Please sign in to comment.