From f88ff86af127a795037be7ba56d3a07319b763d6 Mon Sep 17 00:00:00 2001 From: Aditya Kundurkar <95044988+AK46rocks@users.noreply.github.com> Date: Tue, 16 Apr 2024 03:40:42 +0530 Subject: [PATCH] Docs Env Support (#507) * added env support docs in quickstart guide * added bulid script info * Update quickstart.md --- docs/indexer/quickstart/quickstart.md | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/indexer/quickstart/quickstart.md b/docs/indexer/quickstart/quickstart.md index 1ee08287daa..0a3bd0e8b0c 100644 --- a/docs/indexer/quickstart/quickstart.md +++ b/docs/indexer/quickstart/quickstart.md @@ -117,3 +117,42 @@ For example, to create the [Ethereum Gravatar indexer](./quickstart_chains/ether Once completed, you will have a scaffold project structure from your chosen ABI `functions`/`events`. You can read more about this feature in [Project Scaffolding](../build/introduction.md#evm-project-scaffolding) + +## ENV Support + +SubQuery provides support for environment variables to configure your project dynamically. This enables flexibility in managing different configurations for development, testing, and production environments. + +To utilize environment variable support: + +The .env files are automatically created when you initialize a project using the CLI. You can modify these files to adjust configurations according to your requirements. + +```shell +# Example .env +ENDPOINT=https://polygon-rpc.com +CHAIN_ID=204 +``` + +In your .env files, *CHAIN_ID* and provided *ENDPOINT* of your project are already added you can configure these variables to match your blockchain network settings. Additionally, you can keep sensitive information such as *CONTRACT_ADDRESS* from project.ts in your .env files for added security. + +Multiple ENDPOINT can be added in .env file using comma separated. + +```shell +ENDPOINT=https://polygon-rpc.com,https://polygon.llamarpc.com +``` + +The package.json file includes build scripts that allow you to build with either production (`.env`) or development (`.env.develop`). + +```json +"scripts": { + "build": "subql codegen && subql build", // default is production + "build:develop": "NODE_ENV=develop subql codegen && NODE_ENV=develop subql build" +} +``` +Use `build` script to generate artifacts using the default production .env settings. +Use `build:develop` script to generate artifacts using the development .env.develop settings. + +Using environment variables and .env files provides a convenient way to manage project configurations and keep sensitive information secure. + +Note: Ensure that .env files are included in your project's .gitignore to prevent them from being committed to version control and exposing sensitive information. + +This documentation provides comprehensive guidance on utilizing environment variable support in SubQuery projects for better configurability and security.