feat: enhance API route naming conventions and structure
- Added comprehensive guidelines for API route naming and structure in `ROUTE_NAMING_BEST_PRACTICES.md`. - Updated `ARCHITECHTURE.md` to reference the new best practices document. - Refactored course-related routes to follow new naming conventions, including changes to endpoint paths and validation schemas. - Removed the deprecated course clone route and integrated cloning functionality directly into the course routes. - Adjusted various API methods to ensure consistent usage of HTTP methods and parameter structures across the application.
This commit is contained in:
@@ -21,8 +21,8 @@ class DashStatApi extends BaseApi {
|
||||
* @returns Organization analytics data (enrollments, courses, revenue, students, top courses)
|
||||
*/
|
||||
async fetchOrgStats({ orgId, siteName }: { orgId?: string; siteName?: string }) {
|
||||
await this.execute<typeof classroomio.dash.stats.$post>({
|
||||
requestFn: () => classroomio.dash.stats.$post({ json: { orgId, siteName } }),
|
||||
await this.execute<typeof classroomio.dash.stats.$get>({
|
||||
requestFn: () => classroomio.dash.stats.$get({ query: { orgId, siteName } }),
|
||||
logContext: 'fetching organization stats',
|
||||
onSuccess: (response) => {
|
||||
this.stats = response.data;
|
||||
|
||||
@@ -276,7 +276,7 @@ class OrgApi extends BaseApiWithErrors {
|
||||
async inviteTeamMembers(orgId: string, emails: string[], roleId: number) {
|
||||
return this.execute<InviteTeamResponse>({
|
||||
requestFn: () =>
|
||||
classroomio.organization[':orgId'].team.invite.$post({
|
||||
classroomio.organization[':orgId']['team']['invite']['$post']({
|
||||
param: { orgId },
|
||||
// @ts-expect-error - the json type is not inferred correctly
|
||||
json: { emails, roleId }
|
||||
|
||||
@@ -34,7 +34,7 @@ export type CoursesByOrganizationSiteNameSuccess = Extract<
|
||||
export type CoursesByOrganizationSiteName = CoursesByOrganizationSiteNameSuccess['data'];
|
||||
|
||||
// dashboard analytics types
|
||||
export type GetDashStatsResponse = typeof classroomio.dash.stats.$post;
|
||||
export type GetDashStatsResponse = typeof classroomio.dash.stats.$get;
|
||||
export type DashStatsResponse = InferResponseType<GetDashStatsResponse> | null;
|
||||
export type DashStatsSuccess = Extract<InferResponseType<GetDashStatsResponse>, { success: true }>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user