mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
const c = require("ansi-colors")
|
|
|
|
const requiredEnvs = [
|
|
{
|
|
key: "NEXT_PUBLIC_HANZO_COMMERCE_KEY",
|
|
description:
|
|
"A publishable API key for your Hanzo Commerce store.",
|
|
},
|
|
]
|
|
|
|
function checkEnvVariables() {
|
|
// Build-time skip: the storefront's publishable key is resolved PER-TENANT at
|
|
// runtime (store config keyed by space_id, resolved per-request), so it is not
|
|
// a build-time constant. CI/Docker `next build` sets SKIP_ENV_VALIDATION=1 to
|
|
// pass; the key is validated where it actually matters ā at request time.
|
|
if (process.env.SKIP_ENV_VALIDATION) return
|
|
|
|
const missingEnvs = requiredEnvs.filter(function (env) {
|
|
return !process.env[env.key] && !(env.fallback && process.env[env.fallback])
|
|
})
|
|
|
|
if (missingEnvs.length > 0) {
|
|
console.error(
|
|
c.red.bold("\nš« Error: Missing required environment variables\n")
|
|
)
|
|
|
|
missingEnvs.forEach(function (env) {
|
|
console.error(c.yellow(` ${c.bold(env.key)}`))
|
|
if (env.description) {
|
|
console.error(c.dim(` ${env.description}\n`))
|
|
}
|
|
})
|
|
|
|
console.error(
|
|
c.yellow(
|
|
"\nPlease set these variables in your .env file or environment before starting the application.\n"
|
|
)
|
|
)
|
|
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
module.exports = checkEnvVariables
|