feat(WHE-27): add drizzle db package and typed env config

This commit is contained in:
2026-03-05 03:05:02 +04:00
parent 18168a8dab
commit 8086044938
21 changed files with 631 additions and 28 deletions

View File

@@ -0,0 +1,18 @@
{
"name": "@household/config",
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts"
},
"scripts": {
"build": "bun build src/index.ts --outdir dist --target bun",
"typecheck": "tsgo --project tsconfig.json --noEmit",
"test": "bun test --pass-with-no-tests",
"lint": "oxlint \"src\""
},
"dependencies": {
"@t3-oss/env-core": "^0.13.8",
"zod": "^4.1.5"
}
}

View File

@@ -0,0 +1,33 @@
import { createEnv } from '@t3-oss/env-core'
import { z } from 'zod'
const server = {
NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
LOG_LEVEL: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
APP_URL: z.string().url(),
DATABASE_URL: z.string().url(),
SUPABASE_URL: z.string().url(),
SUPABASE_PUBLISHABLE_KEY: z.string().min(1),
SUPABASE_SERVICE_ROLE_KEY: z.string().min(1),
TELEGRAM_BOT_TOKEN: z.string().min(1),
TELEGRAM_WEBHOOK_SECRET: z.string().min(1),
TELEGRAM_BOT_USERNAME: z.string().min(1),
OPENAI_API_KEY: z.string().min(1),
PARSER_MODEL: z.string().min(1).default('gpt-4.1-mini'),
SENTRY_DSN: z.string().url().optional(),
GCP_PROJECT_ID: z.string().min(1),
GCP_REGION: z.string().min(1).default('europe-west1'),
CLOUD_RUN_SERVICE_BOT: z.string().min(1).default('household-bot'),
SCHEDULER_SHARED_SECRET: z.string().min(1)
}
export const env = createEnv({
server,
runtimeEnv: process.env,
emptyStringAsUndefined: true,
onValidationError: (issues) => {
console.error('Invalid environment variables:')
console.error(JSON.stringify(issues, null, 2))
throw new Error('Environment validation failed')
}
})

View File

@@ -0,0 +1 @@
export { env } from './env'

View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true
},
"include": ["src/**/*.ts"]
}