Skip to content

Commit

Permalink
ar(feat) [DPCP-40]: Parse Services.
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloreale committed Aug 25, 2024
1 parent d5470a7 commit 17fb024
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/model/interfaces/get-private-abilities.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint @typescript-eslint/no-unused-vars:0 */
// @controller/get-private-services.ts
import { whoAmI } from '@controller';
import { PrivatePrisma } from '@model';
Expand Down Expand Up @@ -42,7 +43,7 @@ const getPrivateAbilities = async ({
const supportedQueries: Record<string, any> = {
user: {
query: {
OR: [{ id: { in: loggedUser?.abilitiesIds }, name: { [locale]: name } }, { userOwner: loggedUser?.id }],
OR: [{ id: { in: loggedUser?.abilities } }, { userOwnerId: loggedUser.id }],
},
},
// group: {
Expand Down
5 changes: 3 additions & 2 deletions lib/model/interfaces/get-private-services.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint @typescript-eslint/no-unused-vars:0 */
// @controller/get-private-services.ts
import { PrivatePrisma } from '@model';
import { whoAmI, canI } from '@controller';
Expand Down Expand Up @@ -37,7 +38,7 @@ const getPrivateServices = async ({
const supportedQueries: Record<string, any> = {
user: {
query: {
OR: [{ id: { in: loggedUser?.servicesIds }, name: { [locale]: name } }, { userOwner: loggedUser?.id }],
OR: [{ id: { in: loggedUser?.services } }, { userOwnerId: loggedUser.id }],
},
},
// group: {
Expand All @@ -60,7 +61,7 @@ const getPrivateServices = async ({
const response = await PrivatePrisma.services.findMany(adaptQuery);
return response;
} catch (e) {
throw new Error('Code 000/2: Wrong filter');
throw new Error(`Code 000/2: Wrong filter: ${e}`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/api/v1/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export async function POST(request: CombineRequest) {
const payload = { data: {} };
try {
if (action === 'get-own-abilities') {
payload.data = await GetPrivateAbilities({ filters: ['user'] });
payload.data = await GetPrivateAbilities({ filters: ['user'], user });
} else if (action === 'get-own-services') {
payload.data = await GetPrivateServices({ filters: ['user'] });
payload.data = await GetPrivateServices({ filters: ['user'], user });
} else {
throw new Error('Code 000/1: No specified action');
}
Expand Down

0 comments on commit 17fb024

Please sign in to comment.