Files
hermez-node/api
Eduard S d625cc9287 Allow serving API only via new cli command
- Add new command to the cli/node: `serveapi` that alows serving the API just
  by connecting to the PostgreSQL database.  The mode flag should me passed in
  order to select whether we are connecting to a synchronizer database or a
  coordinator database.  If `coord` is chosen as mode, the coordinator
  endpoints can be activated in order to allow inserting l2txs and
  authorizations into the L2DB.

Summary of the implementation details
- New SQL table with 3 columns (plus `item_id` pk).  The table only contains a
  single row with `item_id` = 1.  Columns:
    - state: historydb.StateAPI in JSON.  This is the struct that is served via
      the `/state` API endpoint.  The node will periodically update this struct
      and store it int he DB.  The api server will query it from the DB to
      serve it.
    - config: historydb.NodeConfig in JSON.  This struct contains node
      configuration parameters that the API needs to be aware of.  It's updated
      once every time the node starts.
    - constants: historydb.Constants in JSON.  This struct contains all the
      hermez network constants gathered via the ethereum client by the node.
      It's written once every time the node starts.
- The HistoryDB contains methods to get and update each one of these columns
  individually.
- The HistoryDB contains all methods that query the DB and prepare objects that
  will appear in the StateAPI endpoint.
- The configuration used in for the `serveapi` cli/node command is defined in
  `config.APIServer`, and is a subset of `node.Config` in order to allow
  reusing the same configuration file of the node if desired.
- A new object is introduced in the api: `StateAPIUpdater`, which contains all
  the necessary information to update the StateAPI in the DB periodically by
  the node.

- Moved the types `SCConsts`, `SCVariables` and `SCVariablesPtr` from
  `syncrhonizer` to `common` for convenience.
2021-03-15 15:35:20 +01:00
..
2021-03-04 18:26:00 -03:00
2020-11-06 09:30:32 +01:00
2020-11-27 10:45:21 +01:00
2020-12-30 12:41:53 +01:00
2021-03-04 18:26:00 -03:00
2020-12-30 12:41:53 +01:00
2021-03-04 18:26:00 -03:00
2021-03-04 18:26:00 -03:00
2021-01-08 15:47:44 +01:00
2021-03-04 18:26:00 -03:00
2021-03-04 18:26:00 -03:00
2021-03-04 18:26:00 -03:00
2020-11-11 09:33:31 +01:00
2020-10-27 12:27:04 +01:00
2021-03-04 18:26:00 -03:00
2021-02-26 12:15:39 +01:00
2021-03-04 18:26:00 -03:00
2021-03-04 18:26:00 -03:00
2021-03-04 18:26:00 -03:00

Hermez API

Easy to deploy and scale API for Hermez operators. You will need to have docker and docker-compose installed on your machine in order to use this repo.

Documentation

As of now the documentation is not hosted anywhere, but you can easily do it yourself by running ./run.sh doc and then opening the documentation in your browser

Mock Up

To use a mock up of the endpoints in the API run ./run.sh doc (UI + mock up server) or ./run.sh mock (only mock up server). You can play with the mocked up endpoints using the web UI, importing swagger.yml into Postman or using your preferred language and using http://localhost:4010 as base URL.

Editor

It is recomended to edit swagger.yml using a dedicated editor as they provide spec validation and real time visualization. Of course you can use your prefered editor. To use the editor run ./run.sh editor and then opening the editor in your browser. Keep in mind that you will need to manually save the file otherwise you will lose the changes you made once you close your browser seshion or stop the server.

Note: Your browser may cache the swagger definition, so in order to see updated changes it may be needed to refresh the page without cache (Ctrl + Shift + R).