Spaces:
Running
Running
Update app/api/me/projects/route.ts
Browse files
app/api/me/projects/route.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { isAuthenticated } from "@/lib/auth";
|
|
| 3 |
import Project from "@/models/Project";
|
| 4 |
import dbConnect from "@/lib/mongodb";
|
| 5 |
import { COLORS } from "@/lib/utils";
|
| 6 |
-
import { Page } from "@/types";
|
| 7 |
|
| 8 |
export async function GET() {
|
| 9 |
const user = await isAuthenticated();
|
|
@@ -89,9 +88,10 @@ export async function POST(request: NextRequest) {
|
|
| 89 |
const path = `${user.name}/${newTitle}`;
|
| 90 |
|
| 91 |
return NextResponse.json({ project, path, ok: true }, { status: 201 });
|
| 92 |
-
} catch (err:
|
|
|
|
| 93 |
return NextResponse.json(
|
| 94 |
-
{ error:
|
| 95 |
{ status: 500 }
|
| 96 |
);
|
| 97 |
}
|
|
|
|
| 3 |
import Project from "@/models/Project";
|
| 4 |
import dbConnect from "@/lib/mongodb";
|
| 5 |
import { COLORS } from "@/lib/utils";
|
|
|
|
| 6 |
|
| 7 |
export async function GET() {
|
| 8 |
const user = await isAuthenticated();
|
|
|
|
| 88 |
const path = `${user.name}/${newTitle}`;
|
| 89 |
|
| 90 |
return NextResponse.json({ project, path, ok: true }, { status: 201 });
|
| 91 |
+
} catch (err: unknown) {
|
| 92 |
+
const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred';
|
| 93 |
return NextResponse.json(
|
| 94 |
+
{ error: errorMessage, ok: false },
|
| 95 |
{ status: 500 }
|
| 96 |
);
|
| 97 |
}
|