Add logging for post creation API requests and responses

Adds console logs to the /api/posts endpoint in server/index.ts to capture incoming payloads and successful post creation data, aiding in debugging.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: f65c3e3d-c2a9-489d-b74e-9278ae76aed3
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/zMxtXds
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sirpiglr 2025-12-03 19:01:14 +00:00
parent bc2f2c6e30
commit 68b1d5cc51

View file

@ -2451,10 +2451,13 @@ export function createServer() {
});
app.post("/api/posts", async (req, res) => {
console.log("[API] POST /api/posts called");
const payload = req.body || {};
console.log("[API] Payload:", JSON.stringify(payload).slice(0, 200));
// Validation
if (!payload.author_id) {
console.log("[API] Error: author_id is required");
return res.status(400).json({ error: "author_id is required" });
}
if (
@ -2523,6 +2526,7 @@ export function createServer() {
.json({ error: error.message || "Failed to create post" });
}
console.log("[API] Post created successfully:", data?.id);
res.json(data);
} catch (e: any) {
console.error("[API] /api/posts exception:", e?.message || String(e));