-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathenv.ts
More file actions
81 lines (71 loc) · 2.88 KB
/
env.ts
File metadata and controls
81 lines (71 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";
export const env = createEnv({
server: {
// Database
DATABASE_URL: z.string().url().min(1),
// Optional: Direct URL for migrations (bypasses connection pooling)
DIRECT_URL: z.string().url().optional(),
// Supabase (optional, for additional integrations)
SUPABASE_URL: z.string().url().optional(),
SUPABASE_ANON_KEY: z.string().optional(),
SUPABASE_SERVICE_ROLE_KEY: z.string().optional(),
// MailerSend (optional, for institution approval emails)
MAILERSEND_API_KEY: z.string().min(1).optional(),
MAILERSEND_FROM_EMAIL: z.string().email().optional(),
MAILERSEND_FROM_NAME: z.string().optional(),
MAILERSEND_APPROVAL_TEMPLATE_ID: z.string().min(1).optional(),
// Google Geocoding (optional, for backfill scripts)
GOOGLE_GEOCODING_API_KEY: z.string().min(1).optional(),
// OpenAI (optional, bulk QR import script)
OPENAI_API_KEY: z.string().min(1).optional(),
// Better Auth user id to attribute bulk imports (optional)
BULK_IMPORT_CONTRIBUTOR_ID: z.string().min(1).optional(),
// Cloudflare R2 Storage
R2_ENDPOINT: z.string().url(),
R2_ACCESS_KEY_ID: z.string(),
R2_SECRET_ACCESS_KEY: z.string(),
R2_BUCKET_NAME: z.string(),
R2_PUBLIC_URL: z.string().url(),
},
/**
* The prefix that client-side variables must have. This is enforced both at
* a type-level and at runtime.
*/
clientPrefix: "NEXT_PUBLIC_",
client: {
// Supabase public configuration
NEXT_PUBLIC_SUPABASE_URL: z.string().url().optional(),
NEXT_PUBLIC_SUPABASE_ANON_KEY: z.string().optional(),
// Google Maps (optional, for admin approval workflow)
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY: z.string().min(1).optional(),
},
/**
* What object holds the environment variables at runtime. This is usually
* `process.env` or `import.meta.env`.
*/
runtimeEnv: {
...process.env,
GOOGLE_GEOCODING_API_KEY: process.env.GOOGLE_GEOCODING_API_KEY,
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
BULK_IMPORT_CONTRIBUTOR_ID: process.env.BULK_IMPORT_CONTRIBUTOR_ID,
NEXT_PUBLIC_SUPABASE_URL: process.env.NEXT_PUBLIC_SUPABASE_URL,
NEXT_PUBLIC_SUPABASE_ANON_KEY: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY:
process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY,
},
/**
* By default, this library will feed the environment variables directly to
* the Zod validator.
*
* This means that if you have an empty string for a value that is supposed
* to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
* it as a type mismatch violation. Additionally, if you have an empty string
* for a value that is supposed to be a string with a default value (e.g.
* `DOMAIN=` in an ".env" file), the default value will never be applied.
*
* In order to solve these issues, we recommend that all new projects
* explicitly specify this option as true.
*/
emptyStringAsUndefined: true,
});