ignoring assignments that cannot be parsed

This commit is contained in:
2024-09-23 22:15:20 -06:00
parent 55cb135d5d
commit eb73b7217f
12 changed files with 97 additions and 90 deletions

View File

@@ -11,12 +11,12 @@ export const GET = async (
}
) =>
await withErrorHandling(async () => {
const settings = await fileStorageService.assignments.getAssignment(
const assignment = await fileStorageService.assignments.getAssignment(
courseName,
moduleName,
assignmentName
);
return Response.json(settings);
return Response.json(assignment);
});
export const PUT = async (

View File

@@ -6,10 +6,27 @@ export const GET = async (
{
params: { courseName, moduleName },
}: { params: { courseName: string; moduleName: string } }
) => await withErrorHandling(async () => {
const settings = await fileStorageService.assignments.getAssignmentNames(
courseName,
moduleName
);
return Response.json(settings);
})
) =>
await withErrorHandling(async () => {
const names = await fileStorageService.assignments.getAssignmentNames(
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);
});

View File

@@ -2,11 +2,12 @@ import { LocalCourse } from "@/models/local/localCourse";
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
import { withErrorHandling } from "@/services/withErrorHandling";
export const GET = async () =>
await withErrorHandling(async () => {
const courses = await fileStorageService.getCourseNames();
return Response.json(courses);
});
// replace with get all settings
// export const GET = async () =>
// await withErrorHandling(async () => {
// const courses = await fileStorageService.getCourseNames();
// return Response.json(courses);
// });
export const POST = async (request: Request) =>
await withErrorHandling(async () => {