Skip to content

Commit

Permalink
chore: add default config values (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters authored Oct 9, 2023
1 parent da98913 commit a39dd38
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ LIMITED_PAGINATION_MAX_ITEMS=100000
DISABLE_API_SCHEMA_DOCS=false
DISABLE_EXTERNAL_API=false
DATABASE_STATEMENT_TIMEOUT_MS=90000
CONTRACT_VERIFICATION_API_URL=https://zksync2-testnet-explorer.zksync.dev
CONTRACT_VERIFICATION_API_URL=http://127.0.0.1:3070
2 changes: 1 addition & 1 deletion packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You need to have a running Worker database, for instructions on how to run the w
- `DATABASE_REPLICA_URL_<<replica_index>>`
- `DATABASE_CONNECTION_IDLE_TIMEOUT_MS`
- `DATABASE_CONNECTION_POOL_SIZE`
- Set `CONTRACT_VERIFICATION_API_URL` to `https://zksync2-testnet-explorer.zksync.dev` for zkSync Era testnet. For zkSync Era mainnet: `https://zksync2-mainnet-explorer.zksync.io`.
- Set `CONTRACT_VERIFICATION_API_URL` to your verification API URL. For zkSync Era testnet use `https://zksync2-testnet-explorer.zksync.dev`. For zkSync Era mainnet - `https://zksync2-mainnet-explorer.zksync.io`.

## Running the app

Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ describe("config", () => {
beforeAll(() => {
process.env = {
NODE_ENV: "test",
DATABASE_URL: "DATABASE_URL",
};
});

Expand All @@ -24,7 +23,7 @@ describe("config", () => {
},
typeORM: {
type: "postgres",
url: "DATABASE_URL",
url: "postgres://postgres:postgres@localhost:5432/block-explorer",
poolSize: 300,
extra: {
idleTimeoutMillis: 60000,
Expand All @@ -40,6 +39,7 @@ describe("config", () => {
swagger: {
enabled: true,
},
contractVerificationApiUrl: "http://127.0.0.1:3070",
disableExternalAPI: false,
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default () => {
};

const getTypeOrmModuleOptions = (): TypeOrmModuleOptions => {
const master = { url: DATABASE_URL };
const master = { url: DATABASE_URL || "postgres://postgres:postgres@localhost:5432/block-explorer" };
const replicaSet = getDatabaseReplicaSet();

return {
Expand Down Expand Up @@ -77,6 +77,6 @@ export default () => {
enabled: DISABLE_API_SCHEMA_DOCS !== "true",
},
disableExternalAPI: DISABLE_EXTERNAL_API === "true",
contractVerificationApiUrl: CONTRACT_VERIFICATION_API_URL,
contractVerificationApiUrl: CONTRACT_VERIFICATION_API_URL || "http://127.0.0.1:3070",
};
};
1 change: 1 addition & 0 deletions packages/worker/src/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("config", () => {
expect(config()).toEqual({
port: 3001,
blockchain: {
rpcUrl: "http://localhost:3050",
rpcCallDefaultRetryTimeout: 30000,
rpcCallQuickRetryTimeout: 500,
rpcCallConnectionTimeout: 20000,
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default () => {
return {
port: parseInt(PORT, 10) || 3001,
blockchain: {
rpcUrl: BLOCKCHAIN_RPC_URL,
rpcUrl: BLOCKCHAIN_RPC_URL || "http://localhost:3050",
rpcCallDefaultRetryTimeout: parseInt(RPC_CALLS_DEFAULT_RETRY_TIMEOUT, 10) || 30000,
rpcCallQuickRetryTimeout: parseInt(RPC_CALLS_QUICK_RETRY_TIMEOUT, 10) || 500,
rpcCallConnectionTimeout: parseInt(RPC_CALLS_CONNECTION_TIMEOUT, 10) || 20000,
Expand Down
4 changes: 2 additions & 2 deletions packages/worker/src/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const typeOrmModuleOptions: DataSourceOptions = {
type: "postgres",
host: process.env.DATABASE_HOST || "localhost",
port: parseInt(process.env.DATABASE_PORT) || 5432,
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
username: process.env.DATABASE_USER || "postgres",
password: process.env.DATABASE_PASSWORD || "postgres",
database: process.env.DATABASE_NAME || "block-explorer",
poolSize: parseInt(process.env.DATABASE_CONNECTION_POOL_SIZE, 10) || 100,
extra: {
Expand Down

0 comments on commit a39dd38

Please sign in to comment.