Across Indexer monorepo
You can read further details on each component's README file
Configuration packages:
@repo/eslint-config:eslintconfigurations@repo/typescript-config:tsconfig.jsons used throughout the monorepo
Other components that need to use these configurations should include the package names in their dev dependencies and then extend the configurations from component-local configuration files. For example:
// a component package.json
{
// ...
"devDependencies": {
// ...
"eslint-config": "workspace:*",
"tsconfig": "workspace:*"
}
}// a component tsconfig.json
{
"extends": "@repo/typescript-config/base.json",
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"],
// ...
}// a component .eslintrc.js
module.exports = {
extends: ["@repo/eslint-config/index.js"],
// ...
};This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
Before getting started, ensure that the following are installed and available in your environment:
- Node.js: Version 20.x
- Redis
- Docker
The development environment requires a set of environment variables to be configured. Please refer to the .env.example file in the root for the complete list of required variables. To set up your configuration, you can copy the template as follows:
cp .env.example .envTo install dependencies for all apps and packages, run the following command from the root of the repository:
pnpm installTo build all apps and packages, run the following command:
pnpm buildNote: Call pnpm install before running pnpm build if you've added a new package or updated dependencies.
-
HubPool Indexer:
To enable the hubpool indexer, set theENABLE_HUBPOOL_INDEXERenvironment variable totrue. -
SpokePool Indexer:
To enable the spoke pool indexer, set theSPOKEPOOL_CHAINS_ENABLEDenvironment variable to a comma-separated list of chain IDs you wish to index (e.g.,SPOKEPOOL_CHAINS_ENABLED=1,10,137).
Additionally, ensure that a corresponding RPC environment variable is set for each enabled chain.
For any additional configuration, refer to the .env.example file for a list of required environment variables.
This repository is configured to use Docker Compose to create a development environment with all external dependencies.
To start the development environment, run the following command:
docker-compose upTo stop the development environment, run the following command:
docker-compose downEach application (the indexer + the api) will run in the development environment. This is
enabled by default and managed by the docker-compose.yml file.
To run the indexer locally, follow the steps below. All commands should be executed from the root directory of the repository.
- Install Dependencies
Install all project dependencies using:
pnpm install- Start Database Services
Launch the required Redis and Postgres services using Docker:
docker compose up redis postgres -d- Run Database Migrations
Copy your .env file over to ./packages/indexer-database/.env:
cp .env ./packages/indexer-database/.envApply database migrations to ensure the schema is up to date:
pnpm db:indexer-database:migrate:run- Build and Start the Indexer
Copy of your .env to apps/node/.env.
cp .env apps/node.envBuild the project and start the indexer application:
pnpm build && pnpm start:indexerTurborepo recommends installing dependencies directly within the component or package that uses them.
To add a dependency to the package.json of the current workspace, run:
pnpm add some-runtime-package
pnpm add -D some-dev-dependency-packageTo add a dependency to a specific workspace by name, regardless of your current directory, use:
pnpm add some-runtime-package --filter someworkspace
pnpm add -D some-dev-dependency-package --filter someworkspaceTo update the root package.json from any location, add or remove dependencies using the -w (workspace root) flag:
pnpm add -w some-runtime-package
pnpm add -wD some-dev-dependency-packageExample:
Avoid putting shared code in any app. Instead, create a new package with the shared code and have the apps import it. To do so, you can use this repo's template package following instructions here.
Learn more about the power of Turborepo: