Skip to content

Commit

Permalink
Allow to override API urls
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Jul 31, 2024
1 parent f244bc8 commit 7a9c20f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ PORT=8080
# RPC_URL_42161=wss://arbitrum-mainnet.io/ws/v3/your-infura-key
# RPC_URL_11155111=https://sepolia.infura.io/v3/your-infura-key

# CoW API
COW_API_BASE_URL=https://api.cow.fi
# COW_API_URL_1=https://api.cow.fi/mainnet
# COW_API_URL_100=https://api.cow.fi/xdai
# COW_API_URL_42161=https://api.cow.fi/arbitrum_one
# COW_API_URL_11155111=https://api.cow.fi/sepolia

# Caching
REDIS_HOST=redis
# REDIS_PORT=6379
Expand Down
6 changes: 5 additions & 1 deletion libs/repositories/src/datasources/cowApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ const COW_API_NETWORK_NAMES: Record<SupportedChainId, string> = {
export const cowApiClients = ALL_CHAIN_IDS.reduce<
Record<SupportedChainId, CowApiClient>
>((acc, chainId) => {
const cowApiUrl =
process.env[`COW_API_URL_${chainId}`] ||
COW_API_BASE_URL + '/' + COW_API_NETWORK_NAMES[chainId];

acc[chainId] = createClient<paths>({
baseUrl: COW_API_BASE_URL + '/' + COW_API_NETWORK_NAMES[chainId],
baseUrl: cowApiUrl,
});

return acc;
Expand Down

0 comments on commit 7a9c20f

Please sign in to comment.