mirror of https://github.com/TZGyn/shortener
update env variables to use zod
parent
ea5806d376
commit
d3db0e9463
@ -1,9 +1,7 @@
|
|||||||
import { drizzle } from 'drizzle-orm/postgres-js'
|
import { drizzle } from 'drizzle-orm/postgres-js'
|
||||||
import postgres from 'postgres'
|
import postgres from 'postgres'
|
||||||
import * as schema from './schema'
|
import * as schema from './schema'
|
||||||
|
import { env } from '$lib/env'
|
||||||
|
|
||||||
const client = postgres(
|
const client = postgres(env.DATABASE_URL)
|
||||||
process.env.DATABASE_URL ??
|
|
||||||
'postgres://postgres:password@127.0.0.1:5432/link-shortener',
|
|
||||||
)
|
|
||||||
export const db = drizzle(client, { schema })
|
export const db = drizzle(client, { schema })
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
const envSchema = z.object({
|
||||||
|
DATABASE_URL: z.string().url(),
|
||||||
|
PUBLIC_SHORTENER_URL: z.string(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const env = envSchema.parse(process.env)
|
||||||
Loading…
Reference in New Issue