Skip to content

pajicf/sn-api

Repository files navigation

Status Network API - Snapi

sn-team

sn-api (the hedgehog) iz blazing fast offchain engine of Status Network written running on NodeJS.

It's responsible for indexing and managing any offchain data for the Status Network Hub, as well as management of Karma points rewarding system done through the offchain actions.

It's the canonical offchain service for official Status Network applications.

How to run the project? 🐉

Requirements ✅

To run the project, you'll need:

  • If setting up using Docker:
    • Installed Docker
    • Installed docker-compose (Bundled with the official Docker setup)
  • If setting up locally

Docker setup

  1. cp .env.docker.example .env
  2. Fill the values
  3. Run docker-compose up
  4. That's it!

(Note) If you've pulled new code files you'll have to rebuild the Docker image using docker-compose build --no-cache node_backend

Manual setup / Installation 🧙

Git

  1. Clone the repo: git clone https://github.com/status-im/sn-api.git
  2. Navigate to the folder: cd sn-api

Installing the dependencies

  1. Run yarn to install the dependencies

Commands 💻

Name Command Description
Build yarn build Builds all the packages inside the project
Linting yarn lint Lints the project using next lint
Running Development yarn dev Runs the project in development mode
Running Production yarn start Runs the project from production build
Database migrations yarn db:migration Runs the migrations on the database
Undoing database migrations yarn db:migration:undo Undoes the migrations on the database
Creating a new database migration yarn db:migration:create Creates a new sequelize migration file
Database seeding yarn db:seed Seeds the data in the database
Undoing database seeding yarn db:seed:undo Undoes the seeding of the database
Creating a new database seed yarn db:seed:create Creates a new sequelize seed file

Running the commands 🏁

To run the server, follow next steps:

Step 1: Create the Postgres database for this project createdb <your_database_name>

Step 2: Create the .env file
cp .env.example .env

The config file .env.production is used for public configuration variables. Private configuration variables are stored inside Jenkins credentials.

Step 3: Fill the missing .env values

Important

Ensure that you've filled all the needed values in the .env

Step 4: Build the project
yarn build

Step 5: Run migrations
yarn db:migration

Step 6: Run seeding
yarn db:seed

Step 5: Run the app
After everything has been completed, to run the app, use the yarn dev command for dev environment or yarn start for production build

Step 6: Enjoy! ٩(^‿^)۶

API Documentation

To ensure our API is transparent and accessible, Swagger is integrated into the project, a tool for API documentation.

🌐 Accessing Swagger

Once the application is up and running, you can explore our API documentation by visiting http://localhost:<SERVER_PORT>/api-docs

Just replace <SERVER_PORT> with the port your server is operating on, typically 3001 by default.

📪 Postman

For those who are more familiar with Postman, there's also a Postman collection provided in the docs/api folder.
It offers a straightforward way to test and understand the various endpoints without diving into the code. Simply import the collection into Postman and start exploring!


sn-team

Made with ❤

by status.network team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors