Admin privileges for /availabilities endpoint (#169)
* List other user's availabilities * /availabilityId methods for other users * Add return statements * Accept userId single value or array * Add zod schema checks * Filter for schedules only with an availability * Adds safeParsing of JSON before safeParsing of zod * Removed console log * Adds safe JSON parsing before .safeParse * Allow API call without necessarily passing userId Allow `/availabilities` call by a regular user without having to pass their userId to make it work Co-authored-by: Syed Ali Shahbaz <[email protected]>
This commit is contained in:
1 parent
0abf286785
commit
d68ce5e72f
3 files changed
+172
-92
No files matched your search
@@ -8,6 +8,7 @@ export const schemaAvailabilityBaseBodyParams = Availability.pick({
|
||||
date: true,
|
||||
scheduleId: true,
|
||||
days: true,
|
||||
userId: true,
|
||||
}).partial();
|
||||
|
||||
export const schemaAvailabilityReadPublic = Availability.pick({
|
||||
@@ -17,9 +18,9 @@ export const schemaAvailabilityReadPublic = Availability.pick({
|
||||
date: true,
|
||||
scheduleId: true,
|
||||
days: true,
|
||||
userId: true,
|
||||
eventTypeId: true,
|
||||
});
|
||||
userId: true,
|
||||
}).merge(z.object({ success: z.boolean().optional() }));
|
||||
|
||||
const schemaAvailabilityCreateParams = z
|
||||
.object({
|
||||
@@ -45,3 +46,13 @@ export const schemaAvailabilityEditBodyParams = schemaAvailabilityBaseBodyParams
|
||||
export const schemaAvailabilityCreateBodyParams = schemaAvailabilityBaseBodyParams.merge(
|
||||
schemaAvailabilityCreateParams
|
||||
);
|
||||
|
||||
export const schemaAvailabilityReadBodyParams = z
|
||||
.object({
|
||||
userId: z.union([z.number(), z.array(z.number())]),
|
||||
})
|
||||
.partial();
|
||||
|
||||
export const schemaSingleAvailabilityReadBodyParams = z.object({
|
||||
userId: z.number(),
|
||||
});
|
||||
Reference in new issue
Block a user