completionId: cgen-f397a58d211b4147ab5db5a0646acafb
cgen-f397a58d211b4147ab5db5a0646acafb
This commit is contained in:
parent
e141e68ef4
commit
43f0ef5ac1
1 changed files with 39 additions and 1 deletions
|
|
@ -131,11 +131,49 @@ export async function createCreatorProfile(req: Request, userId: string) {
|
|||
spotify_profile_url,
|
||||
} = body;
|
||||
|
||||
// Validate required fields
|
||||
if (!username || typeof username !== "string" || username.trim().length === 0) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Username is required and must be a non-empty string" }),
|
||||
{ status: 400, headers: { "Content-Type": "application/json" } },
|
||||
);
|
||||
}
|
||||
|
||||
if (!experience_level) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Experience level is required" }),
|
||||
{ status: 400, headers: { "Content-Type": "application/json" } },
|
||||
);
|
||||
}
|
||||
|
||||
if (!primary_arm) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Primary arm is required" }),
|
||||
{ status: 400, headers: { "Content-Type": "application/json" } },
|
||||
);
|
||||
}
|
||||
|
||||
const normalizedUsername = username.trim().toLowerCase();
|
||||
|
||||
// Check if username already exists
|
||||
const { data: existingCreator } = await supabase
|
||||
.from("aethex_creators")
|
||||
.select("id")
|
||||
.eq("username", normalizedUsername)
|
||||
.single();
|
||||
|
||||
if (existingCreator) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Username is already taken" }),
|
||||
{ status: 409, headers: { "Content-Type": "application/json" } },
|
||||
);
|
||||
}
|
||||
|
||||
const { data, error } = await supabase
|
||||
.from("aethex_creators")
|
||||
.insert({
|
||||
user_id: userId,
|
||||
username,
|
||||
username: normalizedUsername,
|
||||
bio,
|
||||
skills: skills || [],
|
||||
avatar_url,
|
||||
|
|
|
|||
Loading…
Reference in a new issue