Skip to content

Commit

Permalink
build: add script for checking env vars on build
Browse files Browse the repository at this point in the history
  • Loading branch information
jtourkos committed Oct 15, 2024
1 parent 834edc0 commit a871221
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
PORT=string # Optional. The API server port. Defaults to 8080.

NETWORK=string # Required. The network to connect to. See `SupportedChain` in `graphql.ts` for supported networks.

# Required. The RPC configuration. See `SupportedChain` in `graphql.ts` for supported networks.
RPC_CONFIG='{
"MAINNET": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:e2e": "docker compose up --attach app --build --exit-code-from app && docker compose down",
"build:graphql": "graphql-codegen",
"build:contracts": "typechain --target=ethers-v6 --out-dir ./src/generated/contracts ./src/abi/**.json",
"build": "npm run build:contracts && npm run build:graphql && tsc",
"build": "./scripts/check-env-vars.sh && npm run build:contracts && npm run build:graphql && tsc",
"dev": "npx nodemon",
"start": "node dist/index.js",
"check": "tsc --noEmit"
Expand Down
19 changes: 19 additions & 0 deletions scripts/check-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

echo 🤓 Checking env vars...
echo

if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi

required_vars=("RPC_CONFIG" "POSTGRES_CONNECTION_STRING" "DRIPS_API_KEY" "PUBLIC_API_KEYS")

for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "❌ Error: $var is not set."
exit 1
fi
done

echo "✅ All required environment variables are set."

0 comments on commit a871221

Please sign in to comment.