-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathenv.ts
30 lines (26 loc) · 1.37 KB
/
env.ts
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
import * as v from 'valibot'
export const EnvironmentVariableSchema = v.object({
NODE_ENV: v.union([v.literal('development'), v.literal('production'), v.literal('test')]),
HOST: v.string(),
PORT: v.number(),
NEXT_PUBLIC_SITE_URL: v.string('NEXT_PUBLIC_SITE_URL must be a string', [v.url()]),
APP_VERSION: v.string(),
EFP_API_URL: v.string('EFP_API_URL must be a string', [v.url()]),
NEXT_PUBLIC_EFP_API_URL: v.string('NEXT_PUBLIC_EFP_API_URL must be a string', [v.url()]),
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: v.string('NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID must be a string'),
NEXT_PUBLIC_ENS_SUBGRAPH_API_KEY: v.string('NEXT_PUBLIC_ENS_SUBGRAPH_API_KEY must be a string'),
NEXT_PUBLIC_EFP_ACCOUNT_METADATA: v.string('NEXT_PUBLIC_EFP_ACCOUNT_METADATA must be a string'),
NEXT_PUBLIC_EFP_LIST_REGISTRY: v.string('NEXT_PUBLIC_EFP_LIST_REGISTRY must be a string'),
NEXT_PUBLIC_EFP_LIST_RECORDS: v.string('NEXT_PUBLIC_EFP_LIST_RECORDS must be a string'),
NEXT_PUBLIC_EFP_LIST_MINTER: v.string('NEXT_PUBLIC_EFP_LIST_MINTER must be a string'),
})
export type EnvironmentVariable = v.Input<typeof EnvironmentVariableSchema>
export const {
success,
output: env,
issues,
} = v.safeParse(EnvironmentVariableSchema, process.env, { abortEarly: true, abortPipeEarly: true })
if (!success) {
// console.error(issues)
throw new Error('Environment variables are invalid')
}