$ yarn
export NEAR_NETWORK_ID=testnet
export NEAR_NODE_URL=https://rpc.testnet.near.org
export NEAR_WALLET_URL=https://wallet.testnet.near.org
export ROKETO_CONTRACT_NAME=streaming-r-v2.dcversus.testnet
export VAULT_CONTRACT_NAME=vault.vengone.testnet
export INDEXER_DB_URL=postgres://public_readonly:[email protected]/testnet_explorer
export DISABLE_DATABASE_SSL=true
Install docker
and docker-compose
.
Start Docker container with Postgres DB:
docker-compose up -d
Set DB connection string to environment variable:
export DATABASE_URL=postgres://postgres:[email protected]/eco-postgres
Change TypeORM config for development:
In ormconfig.ts
:
- ssl: {
- rejectUnauthorized: false,
- },
+ synchronize: true,
+ ssl: false,
Build the project before executing migrations:
yarn build
Execute all the built migrations:
yarn migrate
yarn start:dev
To drop all the data from your local DB and mirror testnet DB run the following command (it should NOT log any errors):
pg_dump --no-privileges --format c --dbname=$DB_URL | pg_restore --no-owner --clean --if-exists --dbname=$DATABASE_URL
You may need to install postgresql-14
Linux package or brew upgrade postgresql
for macOS first.
If you don't have such Linux package for installation, try adding a custom Postgres PPA: https://www.postgresql.org/download/linux/ubuntu/
Migrations can be generated by comparing live schema of DB with built entities. To generate a migration, do the following:
- Stop backend from running.
- Mirror testnet production DB to local DB using the command from the previous paragraph.
- Build the project with
yarn build
(so all the updated entities files are built). - Generate a migration with
yarn typeorm migration:generate -n "MIGRATION_NAME_HERE"
while replacingMIGRATION_NAME_HERE
placeholder with actual migration name.
At this point you should have a new file generated in src/migrations
folder. For validation, do the following:
- Build the project with
yarn build
(so the fresh migration is built). - Apply it to DB with
yarn migrate
. - Remove
synchronize: true
from ORMConfig file. - Run backend as usual.
If it runs without synchronize: true
option as good as it run with it, then a migration was generated and applied correctly.
Feel free to run client API generation script at any point:
./generate-and-deploy-api-client.sh
After that, use the produced API version in package.json
of frontend app and change VITE_WEB_API_URL
in .env
file to point at you local backend instance.
# Build image with current
docker build .
docker images
# REPOSITORY TAG IMAGE ID CREATED SIZE
# <none> <none> 9d1b89be622a 2 minutes ago 405MB
docker run -p 4001:3000 --env DATABASE_URL=$DB_URL --env DISABLE_DATABASE_SSL=true $ACCESS_STRING
Testnet env vars
- ROKETO_CONTRACT_NAME=streaming-r-v2.dcversus.testnet
- VAULT_CONTRACT_NAME=vault.vengone.testnet
- NEAR_NETWORK_ID=testnet
- NEAR_NODE_URL=https://rpc.testnet.near.org
- NEAR_WALLET_URL=https://wallet.testnet.near.org
- API_HOST=https://api.test.roke.to
- DAPP_HOST=https://app2.test.roke.to
- INDEXER_DB_URL="postgres://public_readonly:[email protected]/testnet_explorer"
Prod env vars
- ROKETO_CONTRACT_NAME=streaming.r-v2.near
- VAULT_CONTRACT_NAME=vault-roketo.near
- NEAR_NETWORK_ID=mainnet
- NEAR_NODE_URL=https://rpc.mainnet.near.org
- NEAR_WALLET_URL=https://wallet.near.org
- API_HOST=https://api.roke.to
- DAPP_HOST=https://app2.roke.to
- INDEXER_DB_URL="postgres://public_readonly:[email protected]/mainnet_explorer"