generated from blockmatic-icebox/powerstack
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(alchemy): env values validation
- Loading branch information
1 parent
a9705fc
commit 9342895
Showing
4 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { z } from 'zod' | ||
import { isAddress } from 'viem' | ||
import dotenv from 'dotenv' | ||
|
||
dotenv.config() | ||
|
||
const envSchema = z.object({ | ||
ALCHEMY_NOTIFY_TOKEN: z.string().min(1, 'Alchemy notify token is required'), | ||
ALCHEMY_ACTIVITY_WEBHOOK_URL: z.string().url('Invalid webhook URL'), | ||
PRESALE_ADDRESS: z.string().refine(isAddress, 'Invalid Ethereum address'), | ||
}) | ||
|
||
const parsedEnv = envSchema.safeParse(process.env) | ||
if (!parsedEnv.success) { | ||
console.error('Environment validation failed:', parsedEnv.error.format()) | ||
process.exit(1) | ||
} | ||
|
||
|
||
export const appConfig = { | ||
alchemyNotifyToken: parsedEnv.data.ALCHEMY_NOTIFY_TOKEN, | ||
alchemyActivityWebhookUrl: parsedEnv.data.ALCHEMY_ACTIVITY_WEBHOOK_URL, | ||
presaleAddress: parsedEnv.data.PRESALE_ADDRESS, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters