If you want to develop and contribute to the Gateway source code, use this guide as a reference for development and starting a server. If you're looking to deploy a Gateway. We suggest using the normal guide found here.
-
A Unix OS
-
Postgres v10+
-
Node.js v12.20.1
Please note there may be some problems with Node v14 LTS or later. If necessary run.
# Install Node.js v12 LTS
nvm install 12
# Or just use v12 LTS if already installed
nvm use 12Before you begin, you'll need to create and configure the Database and User.
# Access PSQL Terminal
sudo -u postgres psql
# Create the arweave database and user
CREATE DATABASE arweave;
CREATE USER arweave WITH ENCRYPTED PASSWORD 'arweave';
GRANT ALL PRIVILEGES ON DATABASE arweave TO arweave;
# Required in order to import blocks from a snapshot
ALTER ROLE arweave WITH SUPERUSER;
# exit PSQL Terminal
exitBy default, there is a development environment you can use located at .env.dev in the repository. This .dev environment is different to the .env.docker environment which is designed for docker usage.
ARWEAVE_NODES=["..."]
DATABASE_HOST=0.0.0.0
DATABASE_PORT=5432
DATABASE_USER=arweave
DATABASE_PASSWORD=arweave
DATABASE_NAME=arweave
ENVIRONMENT=public
PORT=3000
PARALLEL=4
SNAPSHOT=0
INDICES=["App-Name", "app", "domain", "namespace"]Make sure you copy this configuration to .env.
cp .env.dev .envIf at any point or time you want to increase the parallelization level of block synchronization. You should change the PARALLEL variable.
This variable indicates how many blocks to query concurrently. You can change it to any amount of blocks you please.
PARALLEL=16If you want to disable block synchronization. Simply set PARALLEL to 0.
PARALLEL=0For development purposes, you will want to debug Knex migrations.
To spin up the tables for Postgres run:
yarn migrate:latestTo drop the tables run:
yarn migrate:downAssuming everything was smooth with the above. You can now run.
yarn dev:startYou can now test queries on.
http://localhost:3000/graphqlThis webpage should look similar to.
https://arweave.dev/graphqlIf you're doing a lot of work related to do databases. You might want to use yarn dev:restart as it resets the database.
yarn dev:restartIf you're updating the graphql library as seen in types.graphql. You should run yarn dev:gql to update the GraphQL types.
yarn dev:gqlAlso make sure before pushing a commit. The project passes the lint tests.
yarn dev:lintYou can also automatically fix and format files using.
yarn dev:lint --fix