Added env
This commit is contained in:
12
src/lib/env/client.ts
vendored
Normal file
12
src/lib/env/client.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createEnv } from "@t3-oss/env-nextjs";
|
||||
import { z } from "zod";
|
||||
|
||||
export const env = createEnv({
|
||||
client: {
|
||||
NEXT_PUBLIC_BASE_URL: z.string().url(),
|
||||
},
|
||||
runtimeEnv: {
|
||||
NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL,
|
||||
},
|
||||
emptyStringAsUndefined: true,
|
||||
});
|
||||
24
src/lib/env/server.ts
vendored
Normal file
24
src/lib/env/server.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createEnv } from "@t3-oss/env-nextjs";
|
||||
import { z } from "zod";
|
||||
|
||||
export const env = createEnv({
|
||||
server: {
|
||||
PG_USER: z.string().min(1),
|
||||
PG_PASSWORD: z.string().min(1),
|
||||
PG_HOST: z.string().min(1),
|
||||
PG_PORT: z.string().min(1),
|
||||
PG_DATABASE: z.string().min(1),
|
||||
},
|
||||
createFinalSchema: (schema) => {
|
||||
return z.object(schema).transform(s => {
|
||||
const { PG_USER, PG_PASSWORD, PG_HOST, PG_PORT, PG_DATABASE, ...other } = s
|
||||
|
||||
return {
|
||||
...other,
|
||||
DATABASE_URL: `postgres://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/${PG_DATABASE}`,
|
||||
};
|
||||
})
|
||||
},
|
||||
experimental__runtimeEnv: process.env,
|
||||
emptyStringAsUndefined: true,
|
||||
});
|
||||
Reference in New Issue
Block a user