diff --git a/.env.template b/.env.template index be59797..bb888de 100644 --- a/.env.template +++ b/.env.template @@ -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": { diff --git a/package.json b/package.json index b9034b7..b1a0594 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/scripts/check-env-vars.sh b/scripts/check-env-vars.sh new file mode 100755 index 0000000..f63a6ce --- /dev/null +++ b/scripts/check-env-vars.sh @@ -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."