feat: migrate client-side database calls to secure server-side API endpoints

- Create secure server-side API endpoints for course data, marks, exercises, newsfeeds, submissions, and organization management
- Implement role-based permission checking using checkUserCoursePermissions utility
- Move all client-side Supabase calls to authenticated server endpoints in /api/courses/ and /api/org/
- Add proper authentication and authorization middleware via hooks.server.ts
- Update service functions to use getAccessToken() for API authentication
- Ensure data filtering based on user roles (students only see their own data)
- Maintain backward compatibility with existing component interfaces
This commit is contained in:
Rotimi Best
2025-12-05 10:48:01 +01:00
parent bf614fd782
commit ac4fdf1dd3
22 changed files with 986 additions and 200 deletions
@@ -1,5 +0,0 @@
export const load = ({ params = { id: '' } }) => {
return {
courseId: params.id
};
};
@@ -0,0 +1,7 @@
import { browser } from '$app/environment';
export const load = async ({ params = { id: '' } }) => {
return {
courseId: params.id
};
};
@@ -117,7 +117,7 @@
</select> -->
</div>
<RoleBasedSecurity allowedRoles={[1, 2]}>
<p class="hidden w-20 text-lg dark:text-white lg:block" />
<p class="hidden w-20 text-lg lg:block dark:text-white" />
</RoleBasedSecurity>
</div>
@@ -136,7 +136,7 @@
>{$t('course.navItem.people.action')}</StructuredListCell
>
<RoleBasedSecurity allowedRoles={[1, 2]}>
<p class="hidden w-20 text-lg dark:text-white lg:block" />
<p class="hidden w-20 text-lg lg:block dark:text-white" />
</RoleBasedSecurity>
</StructuredListRow>
</StructuredListHead>