Prettier format pending files
This commit is contained in:
parent
2df17dc8ec
commit
a4d2466bd1
2 changed files with 41 additions and 17 deletions
|
|
@ -560,15 +560,18 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
if (data.user) {
|
||||
try {
|
||||
// Try to send via custom SMTP server
|
||||
const verifyResponse = await fetch("/api/auth/send-verification-email", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
redirectTo,
|
||||
fullName: metadata.full_name || null,
|
||||
}),
|
||||
});
|
||||
const verifyResponse = await fetch(
|
||||
"/api/auth/send-verification-email",
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
redirectTo,
|
||||
fullName: metadata.full_name || null,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
const verifyPayload = await verifyResponse.json().catch(() => ({}));
|
||||
|
||||
|
|
|
|||
|
|
@ -541,17 +541,34 @@ export function createServer() {
|
|||
if (!payload.author_id) {
|
||||
return res.status(400).json({ error: "author_id is required" });
|
||||
}
|
||||
if (!payload.title || typeof payload.title !== "string" || !payload.title.trim()) {
|
||||
return res.status(400).json({ error: "title is required and must be a non-empty string" });
|
||||
if (
|
||||
!payload.title ||
|
||||
typeof payload.title !== "string" ||
|
||||
!payload.title.trim()
|
||||
) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "title is required and must be a non-empty string" });
|
||||
}
|
||||
if (!payload.content || typeof payload.content !== "string" || !payload.content.trim()) {
|
||||
return res.status(400).json({ error: "content is required and must be a non-empty string" });
|
||||
if (
|
||||
!payload.content ||
|
||||
typeof payload.content !== "string" ||
|
||||
!payload.content.trim()
|
||||
) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({
|
||||
error: "content is required and must be a non-empty string",
|
||||
});
|
||||
}
|
||||
|
||||
// Validate author_id is a valid UUID format
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
const uuidRegex =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
if (!uuidRegex.test(String(payload.author_id))) {
|
||||
return res.status(400).json({ error: "author_id must be a valid UUID" });
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "author_id must be a valid UUID" });
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -573,7 +590,9 @@ export function createServer() {
|
|||
title: String(payload.title).trim(),
|
||||
content: String(payload.content).trim(),
|
||||
category: payload.category ? String(payload.category).trim() : null,
|
||||
tags: Array.isArray(payload.tags) ? payload.tags.map((t: any) => String(t).trim()) : [],
|
||||
tags: Array.isArray(payload.tags)
|
||||
? payload.tags.map((t: any) => String(t).trim())
|
||||
: [],
|
||||
is_published: payload.is_published ?? true,
|
||||
})
|
||||
.select()
|
||||
|
|
@ -585,7 +604,9 @@ export function createServer() {
|
|||
message: error.message,
|
||||
details: (error as any).details,
|
||||
});
|
||||
return res.status(500).json({ error: error.message || "Failed to create post" });
|
||||
return res
|
||||
.status(500)
|
||||
.json({ error: error.message || "Failed to create post" });
|
||||
}
|
||||
|
||||
res.json(data);
|
||||
|
|
|
|||
Loading…
Reference in a new issue