apibara / dna

Apibara is the fastest platform to build production-grade indexers that connect onchain data to web2 services.
https://www.apibara.com/
Apache License 2.0
168 stars 32 forks source link

[Feature]: local runner: simplify indexers management in local/dev evns #288

Closed bigherc18 closed 7 months ago

bigherc18 commented 7 months ago

To test it out, you can use grpcurl (install it with brew install grpcurl)

First, make sure you're on the repository root folder

Save this json to a file create_indexer.json, don't forget to put your DNA auth key

{
  "indexer_id": "indexer-id",
  "indexer": {
    "name": "indexer-name",
    "source": {
      "filesystem": {
        "path": "examples/console/",
        "script": "starknet_to_console.js"
      }
    },
    "sink_type": "console",
    "environment": {
      "AUTH_TOKEN": "dna_XXXXXX"
    }
  }
}

Start the server

cargo run --package apibara-runner-local --bin apibara-runner-local start

Create an indexer

grpcurl -plaintext -import-path runners/runner-common/proto/runner/v1/ -proto runner.proto -d @ '0.0.0.0:8080' apibara.runner.v1.IndexerRunner/CreateIndexer <create_indexer.json

You can find the indexer logs in the logs folder

❯ ls logs
indexer-name-stderr.log indexer-name-stdout.log

List all indexers

grpcurl -plaintext -import-path runners/runner-common/proto/runner/v1/ -proto runner.proto -d '{}' '0.0.0.0:8080' apibara.runner.v1.IndexerRunner/ListIndexers

Get an indexer

grpcurl -plaintext -import-path runners/runner-common/proto/runner/v1/ -proto runner.proto -d '{"name": "indexer-name"}' '0.0.0.0:8080' apibara.runner.v1.IndexerRunner/GetIndexer

Delete an indexer

grpcurl -plaintext -import-path runners/runner-common/proto/runner/v1/ -proto runner.proto -d '{"name": "indexer-name"}' '0.0.0.0:8080' apibara.runner.v1.IndexerRunner/DeleteIndexer

If you want to avoid installing apibara cli and the plugins and build them instead, you can export the target folder in your PATH with

export PATH=$PATH:$PWD/target/debug