mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
workign on api errors
This commit is contained in:
@@ -1,33 +1,38 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, assignmentName },
|
||||
}: {
|
||||
params: { courseName: string; moduleName: string; assignmentName: string };
|
||||
}
|
||||
) {
|
||||
const settings = await fileStorageService.getAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName
|
||||
);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
export async function PUT(
|
||||
export const PUT = async (
|
||||
request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, assignmentName },
|
||||
}: { params: { courseName: string; moduleName: string; assignmentName: string } }
|
||||
) {
|
||||
const assignment = await request.json()
|
||||
await fileStorageService.updateAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName,
|
||||
assignment
|
||||
);
|
||||
return Response.json({});
|
||||
}
|
||||
}: {
|
||||
params: { courseName: string; moduleName: string; assignmentName: string };
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const assignment = await request.json();
|
||||
await fileStorageService.updateAssignment(
|
||||
courseName,
|
||||
moduleName,
|
||||
assignmentName,
|
||||
assignment
|
||||
);
|
||||
return Response.json({});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) {
|
||||
) => await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getAssignmentNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, pageName },
|
||||
}: { params: { courseName: string; moduleName: string; pageName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getPage(
|
||||
courseName,
|
||||
moduleName,
|
||||
pageName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getPage(
|
||||
courseName,
|
||||
moduleName,
|
||||
pageName
|
||||
);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
export async function PUT(
|
||||
export const PUT = async (
|
||||
request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, pageName },
|
||||
}: { params: { courseName: string; moduleName: string; pageName: string } }
|
||||
) {
|
||||
const page = await request.json()
|
||||
await fileStorageService.updatePage(
|
||||
courseName,
|
||||
moduleName,
|
||||
pageName,
|
||||
page
|
||||
);
|
||||
return Response.json({});
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const page = await request.json();
|
||||
await fileStorageService.updatePage(courseName, moduleName, pageName, page);
|
||||
return Response.json({});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getPageNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getPageNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, quizName },
|
||||
}: { params: { courseName: string; moduleName: string; quizName: string } }
|
||||
) {
|
||||
) => await withErrorHandling(async () => {
|
||||
const quiz = await fileStorageService.getQuiz(
|
||||
courseName,
|
||||
moduleName,
|
||||
quizName
|
||||
);
|
||||
return Response.json(quiz);
|
||||
}
|
||||
})
|
||||
|
||||
export async function PUT(
|
||||
export const PUT = async (
|
||||
request: Request,
|
||||
{
|
||||
params: { courseName, moduleName, quizName },
|
||||
}: { params: { courseName: string; moduleName: string; quizName: string } }
|
||||
) {
|
||||
) => await withErrorHandling(async () => {
|
||||
const quiz = await request.json()
|
||||
await fileStorageService.updateQuiz(
|
||||
courseName,
|
||||
@@ -28,4 +29,4 @@ export async function PUT(
|
||||
quiz
|
||||
);
|
||||
return Response.json({});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{
|
||||
params: { courseName, moduleName },
|
||||
}: { params: { courseName: string; moduleName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getQuizNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getQuizNames(
|
||||
courseName,
|
||||
moduleName
|
||||
);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{ params: { courseName } }: { params: { courseName: string } }
|
||||
) {
|
||||
const settings = await fileStorageService.getModuleNames(courseName)
|
||||
return Response.json(settings);
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const settings = await fileStorageService.getModuleNames(courseName);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function PUT(
|
||||
export const PUT = async (
|
||||
request: Request,
|
||||
{ params: { courseName } }: { params: { courseName: string } }
|
||||
) {
|
||||
const { updatedCourse, previousCourse } = await request.json();
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
const { updatedCourse, previousCourse } = await request.json();
|
||||
|
||||
console.log(updatedCourse);
|
||||
console.log(courseName);
|
||||
console.log(updatedCourse);
|
||||
console.log(courseName);
|
||||
|
||||
// await fileStorageService.saveCourseAsync(updatedCourse, previousCourse);
|
||||
return Response.json({});
|
||||
}
|
||||
// await fileStorageService.saveCourseAsync(updatedCourse, previousCourse);
|
||||
return Response.json({});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET(
|
||||
export const GET = async (
|
||||
_request: Request,
|
||||
{ params: { courseName } }: { params: { courseName: string } }
|
||||
) {
|
||||
if (courseName.includes(".js.map")) {
|
||||
return Response.json({});
|
||||
}
|
||||
const settings = await fileStorageService.getCourseSettings(courseName);
|
||||
return Response.json(settings);
|
||||
}
|
||||
) =>
|
||||
await withErrorHandling(async () => {
|
||||
if (courseName.includes(".js.map")) {
|
||||
return Response.json({});
|
||||
}
|
||||
const settings = await fileStorageService.getCourseSettings(courseName);
|
||||
return Response.json(settings);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
|
||||
import { withErrorHandling } from "@/services/withErrorHandling";
|
||||
|
||||
export async function GET() {
|
||||
const courses = await fileStorageService.getCourseNames();
|
||||
|
||||
return Response.json(courses);
|
||||
}
|
||||
export const GET = async () =>
|
||||
await withErrorHandling(async () => {
|
||||
const courses = await fileStorageService.getCourseNames();
|
||||
return Response.json(courses);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user