This repo manages api endpoints for the YieldScan backend.
We are always working on improving our codebase, and welcome any suggestions or contributions.
-
Create an issue for the improvement.
-
Fork the repo and make changes.
-
Make a PR.
Important packages:
-
src/config: Here we define configurations for the application(supported networks, etc).
-
src/api: Here we define different middlewares and routes for different endpoints.
-
submodules:
- src/models: Schema for the database.
- src/interfaces: Interfaces for the models.
Api Endpoints:
- Validators risk-set:
/api/<network>/rewards/risk-set
- Nominators:
/api/<network>/actors/nominators
- Validator profile:
/api/<network>/validator/<validatorStashId>
- Historic rewards for a nominator:
/<network>/actors/nominator/overall_history?id=<address>&activeEra=<activeEra>
- Council Members:
api/<network>/council/members
- Council Member data:
api/<network>/council/member/<councilMemberAccountId>
-
MongoDb connection url, make sure you have a running mongodb instance.
- this article can help setting an instance locally.
Clone this or forked repository:
git clone --recursive https://github.com/yieldscan/yieldscan-backend-api
Note: --recursive
is for cloning the submodules. If you already have cloned the repository without the --recursive
argument and now want to load it’s submodules you have to run git submodule update --init
inside the main folder of the repo.
cd into the main folder:
cd yieldscan-backend-api
The first time, you will need to run:
npm install
Define the following environment variables in a .env
file inside the main folder:
# MongoDb connection url
MONGODB_URI=<your mongodb connection url>
domain='https://yieldscan.app'
LOG_LEVEL='silly'
Then just start the server with
For development:
npm run dev
It uses nodemon in development for livereloading ✌️
IMPORTANT NOTE: When creating the database for the first time, it would might take around 30-45 minutes for all data endpoints to start functioning.
For production use:
npm start
# or
npm run start
- Run
npm run git:commit
for commiting your code and follow the process.
You can run a docker container via -
docker run -e MONGODB_URI=<your mongodb connection url> -t sahilnanda/yieldscan-api
You can run tests via -
npm run test