-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(frontend): small typos [2024-11-10]
- Loading branch information
1 parent
2b42335
commit 97f004e
Showing
3 changed files
with
232 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
export async function POST(request: NextRequest) { | ||
try { | ||
const authToken = request.cookies.get("sid")?.value; | ||
if (!authToken) { | ||
return NextResponse.json( | ||
{ success: false, error: "Authentication required" }, | ||
{ status: 401 }, | ||
); | ||
} | ||
|
||
const body = await request.json(); | ||
const { name } = body; | ||
|
||
if (!name || typeof name !== "string" || name.trim().length === 0) { | ||
return NextResponse.json( | ||
{ success: false, error: "Workspace name is required" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const response = await fetch(`${process.env.GRIDWALK_API}/workspace`, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${authToken}`, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ name: name.trim() }), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Failed to create workspace: ${response.statusText}`); | ||
} | ||
|
||
return NextResponse.json({ | ||
success: true, | ||
message: "Workspace created successfully", | ||
}); | ||
} catch (error) { | ||
console.error("Error creating workspace:", error); | ||
return NextResponse.json( | ||
{ | ||
success: false, | ||
error: | ||
error instanceof Error ? error.message : "Failed to create workspace", | ||
}, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters