feat(api): env vars check on startup
This commit is contained in:
parent
e0157210df
commit
6cf917afba
@ -6,6 +6,7 @@ import { cors } from 'hono/cors'
|
|||||||
import user from './user'
|
import user from './user'
|
||||||
|
|
||||||
import { authentication } from './utils/authentication'
|
import { authentication } from './utils/authentication'
|
||||||
|
import { startup } from './utils/startup'
|
||||||
|
|
||||||
type User = z.infer<typeof UserOutput>
|
type User = z.infer<typeof UserOutput>
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ app.get(
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
startup()
|
||||||
export default {
|
export default {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
|
23
apps/api/src/utils/startup.ts
Normal file
23
apps/api/src/utils/startup.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
declare module 'bun' {
|
||||||
|
interface Env {
|
||||||
|
POSTGRES_URL: string
|
||||||
|
CLERK_WEBHOOK_SECRET: string
|
||||||
|
CLERK_SECRET_KEY: string
|
||||||
|
CLERK_PUBLISHABLE_KEY: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const startup = () => {
|
||||||
|
const keys = [
|
||||||
|
'POSTGRES_URL',
|
||||||
|
'CLERK_WEBHOOK_SECRET',
|
||||||
|
'CLERK_SECRET_KEY',
|
||||||
|
'CLERK_PUBLISHABLE_KEY',
|
||||||
|
]
|
||||||
|
keys.map((key) => {
|
||||||
|
if (!import.meta.env[key]) {
|
||||||
|
console.error(`Env Var ${key} is missing!`)
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user