Files
portabase/app/api/v1/databases/route.ts
T

24 lines
726 B
TypeScript
Raw Normal View History

2026-05-25 15:09:32 +02:00
import { NextResponse } from "next/server";
2026-05-25 18:31:00 +02:00
import { withApiKey } from "@/lib/api-v1/middleware";
2026-05-25 15:09:32 +02:00
import { logger } from "@/lib/logger";
2026-05-27 22:02:22 +02:00
import { ApiKeyContext } from "@/lib/api-v1/types";
import { getAccessibleDatabases } from "@/lib/api-v1/services/databases";
2026-05-25 15:09:32 +02:00
const log = logger.child({ module: "api/v1/databases" });
export const GET = withApiKey(async (_req: Request, ctx: ApiKeyContext) => {
try {
2026-05-27 22:02:22 +02:00
const databases = await getAccessibleDatabases(ctx.user);
2026-05-25 15:09:32 +02:00
2026-05-27 22:02:22 +02:00
return NextResponse.json({
data: databases,
2026-05-25 15:09:32 +02:00
});
} catch (error) {
log.error({ error }, "Error in GET /api/v1/databases");
2026-05-27 22:02:22 +02:00
return NextResponse.json(
{ error: "Internal server error" },
{ status: 500 }
);
2026-05-25 15:09:32 +02:00
}
2026-05-27 22:02:22 +02:00
});