Clone the repository:
git clone https://github.com/luniehq/lunie-api.git
Install dependencies:
yarn install
Start with automatic restart on save:
yarn dev
Or start using Redis for the Apollo cache. You will need to set REDIS_URL
environment variable with your Redis server URL.
yarn dev-cache
Or start in a docker container:
yarn dev-docker
When running you can access GraphQL Playground at http://localhost:4000/. You can use it to create/test GraphQL queries to the API.
Name | Description |
---|---|
HASURA_URL |
Hasura backend URL |
HASURA_ADMIN_KEY |
Hasura backend admin password |
ENABLE_CACHE |
Enable/disable Apollo Server RedisCache. You must have a Redis server available. |
REDIS_URL |
Redis server URI in <auth>@hostname:port format |
ENGINE_API_KEY |
Enable Apollo GraphQL metrics through https://engine.apollographql.com/ |
SENTRY_DSN |
Sentry (https://sentry.io) data source name in format https://<key>@sentry.io/<project> |
RUN_ONLY_NETWORKS |
Run only the networks with this ID comma separated (allows scaling and better development) |
LOCAL_KUSAMA_API |
Use a local kusama API as the one here is only whitelisted for some IPs |
WHITELIST_ORIGIN |
Allow only some origins to access the API |
A new network only requires 3 things:
- An entry in the
data/networks.json
array. - A class to source information from an external endpoint.
- A class to 'listen' for block events.
For example, the Cosmos Hub classes are defined within the networks.json
config like so:
"source_class_name": "source/cosmosV2-source",
"block_listener_class_name": "block-listeners/cosmos-node-subscription",
Be careful to prefix the path with source
and block-listeners
respectively.
These refer to folders underneath the root lib
directory, and are where the
classes should be placed.
Some notes:
- Networks are automatically loaded and will begin fetching blocks once the application starts.
- To disable a network, set it's
enable
property tofalse
. - Network configurations are validated during testing.