Skip to content

Commit e03135b

Browse files
committed
feat: t3oss env.ts
1 parent d63898f commit e03135b

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

apps/web/app/env.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { createEnv } from "@t3-oss/env-nextjs";
2+
import { z } from "zod";
3+
4+
export const env = createEnv({
5+
/*
6+
* Serverside Environment variables, not available on the client.
7+
* Will throw if you access these variables on the client.
8+
*/
9+
server: {
10+
OPENAI_API_KEY: z.string(),
11+
PINECONE_API_KEY: z.string(),
12+
PINECONE_INDEX_NAME: z.string(),
13+
},
14+
/*
15+
* Environment variables available on the client (and server).
16+
*
17+
* 💡 You'll get type errors if these are not prefixed with NEXT_PUBLIC_.
18+
*/
19+
client: {},
20+
/*
21+
* Due to how Next.js bundles environment variables on Edge and Client,
22+
* we need to manually destructure them to make sure all are included in bundle.
23+
*
24+
* 💡 You'll get type errors if not all variables from `server` & `client` are included here.
25+
*/
26+
runtimeEnv: {
27+
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
28+
PINECONE_API_KEY: process.env.PINECONE_API_KEY,
29+
PINECONE_INDEX_NAME: process.env.PINECONE_INDEX_NAME,
30+
},
31+
});

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@repo/embeddings": "workspace:*",
1616
"@repo/pinecone": "workspace:*",
1717
"@repo/ui": "workspace:*",
18+
"@t3-oss/env-nextjs": "^0.13.4",
1819
"ai": "^4.3.15",
1920
"framer-motion": "^12.12.1",
2021
"lucide-react": "^0.509.0",

pnpm-lock.yaml

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

turbo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"tasks": {
66
"build": {
77
"dependsOn": ["^build"],
8+
"env": ["OPENAI_API_KEY", "PINECONE_API_KEY", "PINECONE_INDEX_NAME"],
89
"inputs": ["$TURBO_DEFAULT$", ".env*"],
910
"outputs": ["dist/**", ".next/**", "!.next/cache/**", "out/**"]
1011
},

0 commit comments

Comments
 (0)