centralizing logic

This commit is contained in:
2024-09-27 10:36:09 -06:00
parent 1112b646f3
commit ae8bd1297e
8 changed files with 335 additions and 176 deletions

View File

@@ -8,25 +8,10 @@ export const GET = async (
}: { params: { courseName: string; moduleName: string } }
) =>
await withErrorHandling(async () => {
const names = await fileStorageService.assignments.getAssignmentNames(
const assignments = await fileStorageService.assignments.getAssignments(
courseName,
moduleName
);
const assignments = (
await Promise.all(
names.map(async (name) => {
try {
return await fileStorageService.assignments.getAssignment(
courseName,
moduleName,
name
);
} catch {
return null;
}
})
)
).filter((a) => a !== null);
return Response.json(assignments);
});