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.
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
- Node.js (Version 22)
- Yarn (Version 4)
- Installed PostgreSQL 17
cp .env.docker.example .env- Fill the values
- Run
docker-compose up - 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
- Clone the repo:
git clone https://github.com/status-im/sn-api.git - Navigate to the folder:
cd sn-api
- Run
yarnto install the dependencies
| 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 |
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! ٩(^‿^)۶
To ensure our API is transparent and accessible, Swagger is integrated into the project, a tool for API documentation.
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.
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!
by status.network team

