diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e81664c --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +ADMIN_DOMAIN = http://localhost:9001 +DATABASE_URL = postgresql://postgres:postgres@localhost:5432/nextplacement +AUTH_SECRET= change_me_to_a_long_random_string \ No newline at end of file diff --git a/apps/student/next.config.mjs b/apps/student/next.config.mjs index 1a8e760..40d3e95 100644 --- a/apps/student/next.config.mjs +++ b/apps/student/next.config.mjs @@ -2,6 +2,7 @@ import path from 'path'; const __dirname = path.resolve(); +const adminDomain = process.env.ADMIN_DOMAIN || "http://localhost:9001"; const nextConfig = { transpilePackages: ['@workspace/ui', '@workspace/db'], @@ -11,15 +12,15 @@ const nextConfig = { return [ { source: '/admin', - destination: `${process.env.ADMIN_DOMAIN}/admin`, + destination: `${adminDomain}/admin`, }, { source: '/admin/:path+', - destination: `${process.env.ADMIN_DOMAIN}/admin/:path+`, + destination: `${adminDomain}/admin/:path+`, }, { source: '/admin-static/:path+', - destination: `${process.env.ADMIN_DOMAIN}/admin-static/:path+`, + destination: `${adminDomain}/admin-static/:path+`, } ]; } diff --git a/packages/db/index.ts b/packages/db/index.ts index b827539..ad51fdd 100644 --- a/packages/db/index.ts +++ b/packages/db/index.ts @@ -1,6 +1,12 @@ import { drizzle } from 'drizzle-orm/neon-http'; import * as schema from './schema.ts'; -export const db = drizzle(process.env.DATABASE_URL!, { schema }); +const databaseUrl = process.env.DATABSE_URL; -export * from './schema.ts'; \ No newline at end of file +if(!databaseUrl) { + throw new Error{ + "DTABASE_URL is missing. Create the required env file (see .env.example) and set DATABASE_URL" + }; +} + +export const db = drizzle(databaseUrl, { schema }); \ No newline at end of file