Middleware service which expose rest api
This module is a part of middleware services. You can install it in 2 ways:
- through core middleware installer middleware installer
- by hands: just clone the repo, do 'npm install', set your .env - and you are ready to go
This module is used for interaction with middleware. This happens through the layer, which is built on node-red. So, you don't need to write any code - you can create your own flow with UI tool supplied by node-red itself. Access by this route:
/admin
description | route | method | params | output |
---|---|---|---|---|
get transactions for the registered address (by default skip = 0, limit=100) | /tx/:addr/history | GET | {addr: <string>, limit: <Number>, skip: <Number> |
[<Object of tx>] view example |
get balance of the registered address | /addr/:addr/balance | GET | {addr: <string>} |
{balance: <Number>, assets: {assetId: <Number>}} view example |
get tx by its hash | /tx/{hash} | GET | {hash: <string>} |
<Object of tx> view example |
register new address on middleware. assets - is an array of assets, which balance changes this address will listen to (optional). | /addr | POST | {address: <string>, assets: [<string>]} |
{code: <Number>, message: <string>} Example: {code: 1, message: 'ok'} |
mark an address as inactive and stop perform any actions for this address. | /addr | DELETE | {address: <string>} |
{code: <Number>, message: <string>} Example: {code: 1, message: 'ok'} |
push passed assets to an existing one for the registered user. | /addr/:addr/token | POST | {addr: <string>, assets: [<string>]} |
{code: <Number>, message: <string>} Example: {code: 1, message: 'ok'} |
delete passed assets from the registered user. | /addr/:addr/token | DELETE | {addr: <string>, assets: [<string>]} |
{code: <Number>, message: <string>} Example: {code: 1, message: 'ok'} |
send signed tx | /tx/send | POST | {tx: <Object of prepared tx>} [view example] (examples/tx_send.md) |
{tx: <Object of tx>} view example |
To apply your configuration, create a .env file in root folder of repo (in case it's not present already). Below is the expamle configuration:
MONGO_ACCOUNTS_URI=mongodb://localhost:27017/data
MONGO_ACCOUNTS_COLLECTION_PREFIX=waves
MONGO_DATA_URI=mongodb://localhost:27017/data
MONGO_DATA_COLLECTION_PREFIX=waves
NODERED_MONGO_URI=mongodb://localhost:27018/data
NODE_RED_MONGO_COLLECTION_PREFIX=rest
REST_PORT=8081
NODERED_AUTO_SYNC_MIGRATIONS=true
API_KEY=password
HTTP_ADMIN=/admin
RPC=http://localhost:6869
The options are presented below:
name | description |
---|---|
MONGO_URI | the URI string for mongo connection |
MONGO_COLLECTION_PREFIX | the default prefix for all mongo collections. The default value is 'waves' |
MONGO_ACCOUNTS_URI | the URI string for mongo connection, which holds users accounts (if not specified, then default MONGO_URI connection will be used) |
MONGO_ACCOUNTS_COLLECTION_PREFIX | the collection prefix for accounts collection in mongo (If not specified, then the default MONGO_COLLECTION_PREFIX will be used) |
MONGO_PROFILE_URI | the URI string for mongo connection, which holds profile accounts (if not specified, then default MONGO_URI connection will be used) [for token from laborx] |
MONGO_PROFILE_COLLECTION_PREFIX | the collection prefix for profile collection in mongo (If not specified, then the default MONGO_COLLECTION_PREFIX will be used) [for token from laborx] |
MONGO_DATA_URI | the URI string for mongo connection, which holds data collections (for instance, processed block's height). In case, it's not specified, then default MONGO_URI connection will be used) |
MONGO_DATA_COLLECTION_PREFIX | the collection prefix for data collections in mongo (If not specified, then the default MONGO_COLLECTION_PREFIX will be used) |
NODERED_MONGO_URI | the URI string for mongo connection, which holds data collections (for instance, processed block's height). In case, it's not specified, then default MONGO_URI connection will be used) |
NODE_RED_MONGO_COLLECTION_PREFIX | the collection prefix for node-red collections in mongo (If not specified, then the collections will be created without prefix) |
REST_PORT | rest plugin port |
NODERED_AUTO_SYNC_MIGRATIONS | autosync migrations on start (default = yes) |
API_KEY | api key for node waves [private requests] |
HTTP_ADMIN | admin path for nodered or false (if not publish as default) |
RPC | the path to waves rest api for get balance for user |
LABORX | url for laborxAuth [default=http://localhost:3001/api/v1/security] |
LABORX_RABBIT_SERVICE_NAME | service name for laborx[exchange=events] in rabbitMq |
LABORX_RABBIT_URI | rabbit uri for laborx [exchange=events] |
name | description |
---|---|
ACCOUNT_ONE | address for first account |
ACCOUNT_TWO | address for second account |
PRIVATE_KEY_ONE | private key for first account |
PUBLIC_KEY_ONE | public key for first account |
PRIVATE_KEY_TWO | private key for second account |
PUBLIC_KEY_TWO | public key for second account |
SEED_PHARSE_ONE | seed pharse for first account |
SYSTEM_RABBIT_URI | rabbitmq URI connection string for infrastructure |
SYSTEM_RABBIT_SERVICE_NAME | rabbitmq service name for infrastructure |
SYSTEM_RABBIT_EXCHANGE | rabbitmq exchange name for infrastructure |
CHECK_SYSTEM | check infrastructure or not (default = true) |
LABORX | url for laborxAuth [default=http://localhost:3001/api/v1/security] |
LABORX_RABBIT_SERVICE_NAME | service name for laborx[exchange=events] in rabbitMq |
LABORX_RABBIT_URI | rabbit uri for laborx [exchange=events] |
LABORX_USE_AUTH | use laborx auth or not (default=true) |
LABORX_USE_CACHE | use laborx auth cache in mongo or not (default=true) |
LaborX PTY