mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 12:04:02 +00:00
feat(WHE-27): add drizzle db package and typed env config
This commit is contained in:
18
packages/config/package.json
Normal file
18
packages/config/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
33
packages/config/src/env.ts
Normal file
33
packages/config/src/env.ts
Normal 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')
|
||||
}
|
||||
})
|
||||
1
packages/config/src/index.ts
Normal file
1
packages/config/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { env } from './env'
|
||||
7
packages/config/tsconfig.json
Normal file
7
packages/config/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user