Categorygithub.com/uvio-network/apiserver
modulepackage
0.0.0-20241205113131-92ca40271688
Repository: https://github.com/uvio-network/apiserver.git
Documentation: pkg.go.dev

# README

apiserver

Golang based Twirp apiserver. Requires at least go1.22.5.

./apiserver -h
Golang based RPC apiserver.

Usage:
  apiserver [flags]
  apiserver [command]

Available Commands:
  daemon      Execute the long running process exposing RPC server handlers.
  version     Print version information of this command line tool.

Flags:
  -h, --help   help for apiserver

Use "apiserver [command] --help" for more information about a command.

development

Running redis stack locally. The data explorer of the redis instance is available at http://localhost:8001. This frontend is very useful to understand and debug the maintained state in redis.

docker run --rm --name redis-stack-apiserver -p 6379:6379 -p 8001:8001 redis/redis-stack:latest

For standalone redis instances we can run the redis insights dashboard separately and add any database there that we want to connect to.

docker run --rm --name redis-insight -p 5540:5540 redis/redisinsight:latest

Running the apiserver locally requires a proper .env.local file according to the structure of .env.fake but with real data, depending on your desired use case. For instance, if you want to run the apiserver alongside the webclient, then you need to configure some Auth Provider relevant information.

./apiserver daemon
{ "time":"2024-07-24 10:07:46", "leve":"info", "mess":"server listening for calls", "addr":"127.0.0.1:7777", "call":"/Users/xh3b4sd/project/uvio-network/apiserver/pkg/server/server.go:86" }
{ "time":"2024-07-24 10:07:46", "leve":"info", "mess":"worker searching for tasks", "addr":"127.0.0.1:6379", "call":"/Users/xh3b4sd/project/uvio-network/apiserver/pkg/worker/worker.go:55" }

Calling the apiserver locally at / returns a simple health check response.

curl -s http://127.0.0.1:7777
OK

Calling the apiserver locally at /version returns the project's version information.

curl -s http://127.0.0.1:7777/version | jq .
{
  "arc": "arm64",
  "gos": "darwin",
  "sha": "n/a",
  "src": "https://github.com/uvio-network/apiserver",
  "tag": "n/a",
  "ver": "go1.22.5"
}

Creating a post object locally looks something like the following. All server handlers follow the same design pattern. If you know the data structure of the input object, then you should be able to call any server handler by sending some JSON using a POST request.

curl -s --request "POST" --header "Content-Type: application/json" --data '{"object":[{"public":{"text":"foo bar", "token": "WETH"}}]}' http://127.0.0.1:7777/post.API/Create | jq .
{
  "filter": null,
  "object": [
    {
      "intern": {
        "created": "1721826156",
        "id": "1721826156886308"
      },
      "public": null
    }
  ]
}

Generating smart contract bindings using abigen.

abigen --abi pkg/contract/claimscontract/Claims.ABI.v.0.4.0.json --pkg claimscontract --type ClaimsContractBindingV_0_4_0 --out pkg/contract/claimscontract/claimscontract_binding_v_0_4_0.go
abigen --abi pkg/contract/claimscontract/Claims.ABI.v.0.5.0.json --pkg claimscontract --type ClaimsContractBindingV_0_5_0 --out pkg/contract/claimscontract/claimscontract_binding_v_0_5_0.go
abigen --abi pkg/contract/uvxcontract/UVX.ABI.json --pkg uvxcontract --type UvxContractBinding --out pkg/contract/uvxcontract/uvxcontract_binding.go

testing

Test data can be generated by running the command below.

./apiserver fakeit

# Packages

No description provided by the author
No description provided by the author