feat: move community supabase request to api layer (#612)
* feat: move community supabase request to api layer * chore: pr review checkpoint * chore: PR fixes * feat: implement role-based authorization middleware and align the community features with the developer guide. - Added role-based authorization middleware for organization and course membership checks, including `orgMemberMiddleware`, `orgTeamMemberMiddleware`, and `courseMemberMiddleware`. - Introduced route-specific middleware for comment and question authorization, ensuring only authors or team members can modify content. - Updated community routes to utilize the new middleware for enhanced security and access control. - Refactored community services to streamline upvote functionality and improve error handling. - Enhanced UI components for community interactions, including new comment and question pages, and improved state management for user actions. - Updated documentation to reflect new middleware usage and best practices for authorization in the API layer. * feat: enhance course and organization routes with middleware for improved access control - Added `courseMemberMiddleware` to course download and clone routes to enforce membership checks. - Updated lesson route to include `courseMemberMiddleware` for PDF downloads. - Integrated `orgMemberMiddleware` into organization routes for team and audience access, ensuring only authorized members can retrieve data. - Refactored lesson and organization routes for consistency and clarity in middleware usage. * chore: streamline dashboard and API development scripts in package.json - Consolidated dashboard and API development commands to include all relevant filters in a single line for improved clarity and ease of use. - Removed redundant full command variants to simplify the script section. --------- Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
co-authored by
Rotimi Best
parent
9fb6c7cbaa
commit
bc9e3b41ae
@@ -0,0 +1,69 @@
|
||||
import * as z from 'zod';
|
||||
|
||||
export const ZCommunityQuestions = z.object({
|
||||
orgId: z.string().min(1, 'orgId is required')
|
||||
});
|
||||
|
||||
export const ZCommunityQuestion = z.object({
|
||||
slug: z.string().min(1, 'slug is required')
|
||||
});
|
||||
|
||||
export const ZNewCommunityQuestion = z.object({
|
||||
slug: z.string().min(1, 'slug is required'),
|
||||
body: z.string().min(1, 'body is required'),
|
||||
title: z.string().min(1, 'title is required'),
|
||||
courseId: z.string().min(1, 'courseId is required'),
|
||||
organizationId: z.string().min(1, 'organizationId is required'),
|
||||
authorProfileId: z.string().min(1, 'authorProfileId is required'),
|
||||
votes: z.number().optional()
|
||||
});
|
||||
|
||||
export const ZCreateCommunityQuestion = z.object({
|
||||
body: z.string().min(1),
|
||||
title: z.string().min(1),
|
||||
courseId: z.string().optional()
|
||||
});
|
||||
|
||||
export const ZGetCommunity = z.object({
|
||||
id: z.coerce.number()
|
||||
});
|
||||
|
||||
export const ZCommunityQuestionUpdate = z.object({
|
||||
title: z.string().min(1, 'title is required'),
|
||||
body: z.string().min(1, 'body is required'),
|
||||
courseId: z.string().min(1, 'courseId is required')
|
||||
});
|
||||
|
||||
// --- comment
|
||||
export const ZCommunityCommentDelete = z.object({
|
||||
id: z.string().min(1, 'id is required')
|
||||
});
|
||||
|
||||
export const ZGetCommunityCommentQuestionId = z.object({
|
||||
questionId: z.coerce.number()
|
||||
});
|
||||
|
||||
export const ZCommunityComment = z.object({
|
||||
body: z.string().min(1, 'body is required'),
|
||||
authorProfileId: z.string().min(1, 'authorProfileId is required'),
|
||||
votes: z.number().optional()
|
||||
});
|
||||
|
||||
export const ZUpvotePost = z.object({
|
||||
isQuestion: z.boolean()
|
||||
});
|
||||
|
||||
export const ZUpvotePostParam = z.object({
|
||||
id: z.union([z.string().min(1, 'id is required'), z.number().min(1, 'id is required')])
|
||||
});
|
||||
|
||||
export type TNewCommunityQuestion = z.infer<typeof ZNewCommunityQuestion>;
|
||||
export type TCreateCommunityQuestion = z.infer<typeof ZCreateCommunityQuestion>;
|
||||
export type TCommunityQuestions = z.infer<typeof ZCommunityQuestions>;
|
||||
export type TCommunityQuestion = z.infer<typeof ZCommunityQuestion>;
|
||||
|
||||
export type TCommunityComment = z.infer<typeof ZCommunityComment>;
|
||||
export type TUpvotePost = z.infer<typeof ZUpvotePost>;
|
||||
|
||||
export type TCommunityCommentDelete = z.infer<typeof ZCommunityCommentDelete>;
|
||||
export type TGetCommunity = z.infer<typeof ZGetCommunity>;
|
||||
@@ -0,0 +1 @@
|
||||
export * from './community';
|
||||
Reference in New Issue
Block a user