feat: add direct PostgreSQL and ACK deployment support
This commit is contained in:
@@ -5,6 +5,7 @@ import { getVisibleImageCapabilities } from "@/lib/jimeng/capabilities";
|
||||
import { shouldMockVisualApi } from "@/lib/volcengine/visual-client";
|
||||
import { getSeedanceConfig, shouldMockSeedance } from "@/lib/seedance/client";
|
||||
import { getBailianConfig, shouldMockBailian } from "@/lib/bailian/client";
|
||||
import { getDatabaseStatus } from "@/lib/server/database";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
@@ -12,6 +13,12 @@ export async function GET() {
|
||||
const evolink = getEvolinkImageSettings();
|
||||
const auth = getAuthRuntimeConfig();
|
||||
const bailian = getBailianConfig();
|
||||
let database: { backend: "local" | "postgres" | "invalid"; configured: boolean };
|
||||
try {
|
||||
database = getDatabaseStatus();
|
||||
} catch {
|
||||
database = { backend: "invalid", configured: false };
|
||||
}
|
||||
return jsonOk({
|
||||
ok: true,
|
||||
appId: "zhinian-web-studio",
|
||||
@@ -21,6 +28,7 @@ export async function GET() {
|
||||
seedanceMode: shouldMockSeedance() ? "mock" : "seedance",
|
||||
bailianMode: shouldMockBailian() ? "mock" : bailian.apiKey ? "bailian" : "missing",
|
||||
authMode: authConfigSummary(auth),
|
||||
database,
|
||||
capabilities: [
|
||||
...getVisibleImageCapabilities().map((capability) => {
|
||||
const engine = getEffectiveImageEngine(capability.id);
|
||||
|
||||
31
app/api/ready/route.ts
Normal file
31
app/api/ready/route.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { checkDatabaseReadiness, getDatabaseStatus } from "@/lib/server/database";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
const READINESS_TIMEOUT_MS = 3_000;
|
||||
|
||||
export async function GET() {
|
||||
let database: { backend: "local" | "postgres" | "invalid"; configured: boolean };
|
||||
try {
|
||||
database = getDatabaseStatus();
|
||||
} catch {
|
||||
database = { backend: "invalid", configured: false };
|
||||
return NextResponse.json({ ok: false, database }, { status: 503 });
|
||||
}
|
||||
|
||||
let timeout: ReturnType<typeof setTimeout> | undefined;
|
||||
try {
|
||||
await Promise.race([
|
||||
checkDatabaseReadiness(),
|
||||
new Promise<never>((_, reject) => {
|
||||
timeout = setTimeout(() => reject(new Error("Database readiness timed out")), READINESS_TIMEOUT_MS);
|
||||
})
|
||||
]);
|
||||
return NextResponse.json({ ok: true, database });
|
||||
} catch {
|
||||
return NextResponse.json({ ok: false, database }, { status: 503 });
|
||||
} finally {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export default function BillingError({ reset }: { error: Error & { digest?: stri
|
||||
<div className="billing-route-error-card">
|
||||
<span className="billing-route-error-kicker">计费中心</span>
|
||||
<h1>计费服务暂时不可用</h1>
|
||||
<p>请先刷新页面。如果平台使用 Supabase,请确认已在 SQL Editor 执行最新的 <code>supabase/schema.sql</code>。</p>
|
||||
<p>请先刷新页面。如果问题持续,请检查服务端日志,并确认已通过 <code>npm run db:migrate</code> 完成数据库迁移。</p>
|
||||
<button type="button" onClick={() => reset()}>重新加载</button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user