Add debug endpoint for todos DB diagnostics
Some checks failed
CI/CD / test (push) Successful in 23s
CI/CD / deploy (push) Failing after 1s

This commit is contained in:
2026-01-30 05:02:06 +00:00
parent fd823e2d75
commit cbfeb6db70

View File

@@ -2,6 +2,7 @@ import { Elysia, t } from "elysia";
import { db } from "../db";
import { todos } from "../db/schema";
import { eq, and, asc, desc, sql } from "drizzle-orm";
import type { SQL } from "drizzle-orm";
import { auth } from "../lib/auth";
const BEARER_TOKEN = process.env.API_BEARER_TOKEN || "hammer-dev-token";
@@ -33,7 +34,22 @@ export const todoRoutes = new Elysia({ prefix: "/api/todos" })
}
console.error("Todo route error:", msg);
set.status = 500;
return { error: "Internal server error" };
return { error: "Internal server error", debug: msg };
})
// Debug endpoint - test DB connectivity for todos table
.get("/debug", async () => {
try {
const result = await db.execute(sql`SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = 'todos')`);
const enumResult = await db.execute(sql`SELECT EXISTS (SELECT FROM pg_type WHERE typname = 'todo_priority')`);
return {
todosTableExists: result,
todoPriorityEnumExists: enumResult,
dbConnected: true
};
} catch (e: any) {
return { error: e.message, dbConnected: false };
}
})
// GET all todos for current user