This Turborepo starter is maintained by the Turborepo core team.
Run the following command:
npx create-turbo@latest
This Turborepo includes the following packages/apps:
docs
: a Next.js appweb
: another Next.js app@repo/ui
: a stub React component library shared by bothweb
anddocs
applications@repo/eslint-config
:eslint
configurations (includeseslint-config-next
andeslint-config-prettier
)@repo/typescript-config
:tsconfig.json
s used throughout the monorepo
Each package/app is 100% TypeScript.
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
To build all apps and packages, run the following command:
cd my-turborepo
pnpm build
To develop all apps and packages, run the following command:
cd my-turborepo
pnpm dev
Tip
Vercel Remote Cache is free for all plans. Get started today at vercel.com.
Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:
cd my-turborepo
npx turbo login
This will authenticate the Turborepo CLI with your Vercel account.
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
npx turbo link
Learn more about the power of Turborepo:
- Install or update nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash source ~/.nvm/nvm.sh
- Use nvm to install and use Node.js v20:
nvm install 20 nvm use 20
Follow these steps to get the project up and running locally, run migrations, and troubleshoot common issues.
- Node.js: version >= 20.0.0
Download from https://nodejs.org/en/download/ - pnpm: package manager
Install vianpm install -g pnpm
- Docker & Docker-Compose
Install from https://docs.docker.com/get-docker/
-
Verify Node.js version
node --version # Should output v20.x.x or higher
-
Install dependencies
pnpm install
Bring up the Postgres container (and any other services defined in docker-compose.yml
):
docker-compose up -d
Change into the db
package and run Drizzle migrations:
cd packages/db
pnpm run db:migrate:incentives
Troubleshooting
If you see an error about missingDATABASE_URL
, you need to export it first.
Drizzle needs the DATABASE_URL
environment variable to connect to Postgres. Based on your docker-compose.yml
, it can look like this:
export DATABASE_URL="postgres://postgres:password@localhost:5432/radix-incentives"
Then re-run the migration:
pnpm run db:migrate:incentives
To port forward the mainnet gateway service, ensure you have the role-admin-developer
role assigned on the production cluster rtjl-prod
. The active mainnet gateway namespace can be either ng-babylon-mainnet-green
or ng-babylon-mainnet-blue
.
-
Switch to the production context:
kubectl config use-context rtlj-prod
-
Port forward the gateway API service:
kubectl port-forward service/gateway-api 8080:8080 -n ng-babylon-mainnet-green
Note: Verify the active namespace (
ng-babylon-mainnet-green
orng-babylon-mainnet-blue
) before executing the port forward command.
If you are starting with a fresh database, you need to seed it with initial data. Change into the db
package directory and run the following command:
pnpm db:seed
Once the gateway API service is port-forwarded, running docker-compose
will also start a local Redis instance. You need to export the following environment variables to ensure your application can connect to the gateway and Redis:
export GATEWAY_URL="http://localhost:8080"
export REDIS_HOST="localhost"
export REDIS_PORT=6379
export REDIS_PASSWORD=password
To trigger the snapshot worker manually, you can use the following command. This is useful for testing purposes or when you need to process a snapshot job immediately.
-
Ensure your environment variables are set correctly, especially
DATABASE_URL
,GATEWAY_URL
,REDIS_HOST
,REDIS_PORT
, andREDIS_PASSWORD
. -
Use the following command to add a job to the snapshot queue. Below code needs to be added to apps/workers/src/index.ts
import { snapshotQueue } from "./snapshot/queue"; import { getHourStartInUTC } from "./helpers/getHourStartInUTC"; snapshotQueue.queue.add("snapshot", { addresses: ['address1', 'address2'], // Replace with actual addresses timestamp: getHourStartInUTC().toISOString(), });
Note: Replace
'address1', 'address2'
with the actual addresses you want to process in the snapshot job.
To run the workers, use the following command:
pnpm dev:workers
- Node.js Downloads & Docs
https://nodejs.org/en/download/ - pnpm Docs
https://pnpm.io/ - Drizzle ORM Migrations
https://orm.drizzle.team/docs/getting-started - Docker-Compose Reference
https://docs.docker.com/compose/