Add debug endpoint for todos DB diagnostics
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user