37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
// Next.js instrumentation hook — runs once when the server process starts.
|
|||
|
|
// Surfaces "silently disabled" integrations at boot so a misconfigured deploy is
|
||
|
|
// obvious in the logs instead of failing quietly at runtime.
|
||
|
|
export function register() {
|
||
|
|
// Only run in the Node.js server runtime (not edge/middleware) and only in prod.
|
||
|
|
if (process.env.NEXT_RUNTIME !== "nodejs") return
|
||
|
|
if (process.env.NODE_ENV !== "production") return
|
||
|
|
|
||
|
|
const warn = (msg: string) => console.warn(`[startup] ⚠ ${msg}`)
|
||
|
|
|
||
|
|
const spacesConfigured =
|
||
|
|
process.env.SPACES_KEY && process.env.SPACES_SECRET && process.env.SPACES_BUCKET
|
||
|
|
if (!spacesConfigured) {
|
||
|
|
warn(
|
||
|
|
"Object storage (SPACES_*) is NOT configured — uploads fall back to local disk, " +
|
||
|
|
"which is EPHEMERAL on App Platform. Uploaded files are lost on every deploy/restart. " +
|
||
|
|
"Configure DigitalOcean Spaces."
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
const smtpConfigured = process.env.SMTP_HOST && process.env.SMTP_USER && process.env.SMTP_PASS
|
||
|
|
if (!smtpConfigured) {
|
||
|
|
warn(
|
||
|
|
"SMTP (SMTP_HOST / SMTP_USER / SMTP_PASS) is NOT configured — all outbound email " +
|
||
|
|
"(rent reminders, overdue/lease alerts, team invites, password resets) will silently fail."
|
||
|
|
)
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!process.env.STRIPE_SECRET_KEY) {
|
||
|
|
warn("STRIPE_SECRET_KEY is NOT set — checkout/billing and rent payment links are disabled.")
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!process.env.OPENAI_API_KEY) {
|
||
|
|
warn("OPENAI_API_KEY is NOT set — AI features will error when called.")
|
||
|
|
}
|
||
|
|
}
|