Files
zpan/server/bootstrap.ts
T
saltbo 3064403c92 fix(ids): make normalization optional
Keep historical identifiers readable and addressable while generating all new entity IDs with Base62. Reject unsafe external ID references and preserve API keys and device codes during optional normalization.
2026-08-05 13:06:41 -04:00

23 lines
849 B
TypeScript

import { createApp } from './app'
import { createAuth } from './auth'
import { createDeps } from './composition'
import type { Platform } from './platform/interface'
import type { Deps } from './usecases/deps'
export async function createBootstrap(platform: Platform, deps: Deps = createDeps(platform)) {
const secret = platform.getEnv('BETTER_AUTH_SECRET')
if (!secret) {
throw new Error('BETTER_AUTH_SECRET is required. Set it in the environment before starting the server.')
}
const baseURL = platform.getEnv('BETTER_AUTH_URL') || 'http://localhost:5185'
const trustedOrigins = platform
.getEnv('TRUSTED_ORIGINS')
?.split(',')
.map((o) => o.trim())
.filter(Boolean) || ['http://localhost:5185']
const auth = await createAuth(platform, secret, baseURL, trustedOrigins)
return createApp(platform, auth, deps)
}