diff --git a/.env.example b/.env.example index cdbae85b..a0cd4549 100644 --- a/.env.example +++ b/.env.example @@ -15,7 +15,7 @@ NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL="/dashboard" # ----------------------------------------------------------------------------- # Database (Neon - PostgreSQL) # ----------------------------------------------------------------------------- -NEXT_PUBLIC_DATABASE_URL= +DATABASE_URL= # ----------------------------------------------------------------------------- # Stripe diff --git a/apps/www/env.ts b/apps/www/env.ts index 5d354f03..3955fea2 100644 --- a/apps/www/env.ts +++ b/apps/www/env.ts @@ -18,6 +18,7 @@ export const env = createEnv({ // DATABASE_PASSWORD: z.string().min(1), STRIPE_API_KEY: z.string().min(1).optional(), STRIPE_WEBHOOK_SECRET: z.string().min(1).optional(), + DATABASE_URL: z.string().url(), }, /** * Specify your client-side environment variables schema here. @@ -29,7 +30,6 @@ export const env = createEnv({ NEXT_PUBLIC_STRIPE_STD_MONTHLY_PRICE_ID: z.string().min(1).optional(), NEXT_PUBLIC_STRIPE_PRO_PRODUCT_ID: z.string().min(1).optional(), NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID: z.string().min(1).optional(), - NEXT_PUBLIC_DATABASE_URL: z.string().url(), }, /** * Destructure all variables from `process.env` to make sure they aren't tree-shaken away. @@ -46,7 +46,6 @@ export const env = createEnv({ process.env.NEXT_PUBLIC_STRIPE_PRO_PRODUCT_ID, NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID: process.env.NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID, - NEXT_PUBLIC_DATABASE_URL: process.env.NEXT_PUBLIC_DATABASE_URL, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index a5d0786e..392a5dec 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -1,8 +1,3 @@ -import { neon, Pool } from "@neondatabase/serverless"; -// import { drizzle } from "drizzle-orm/neon-http"; -import { drizzle } from 'drizzle-orm/neon-serverless'; -import { customAlphabet } from "nanoid"; - import * as asset from "./schema/asset"; import * as countryCode from "./schema/country"; import * as currency from "./schema/currency"; @@ -10,6 +5,12 @@ import * as customer from "./schema/customer"; import * as openbanking from "./schema/openbanking"; import * as provider from "./schema/provider"; +import { Pool, neon } from "@neondatabase/serverless"; + +import { customAlphabet } from "nanoid"; +// import { drizzle } from "drizzle-orm/neon-http"; +import { drizzle } from 'drizzle-orm/neon-serverless'; + export const schema = { ...countryCode, ...currency, @@ -36,10 +37,8 @@ export * from "./enum"; export * from "drizzle-orm"; -import { env } from "../../../apps/www/env"; - const pool = new Pool({ - connectionString: env.NEXT_PUBLIC_DATABASE_URL!, + connectionString: process.env.DATABASE_URL, }); export const db = drizzle(