Back-end code repository for the Saving Satoshi platform. You can find our front-end code repository here.
TBD
This guide will help you set up this project for local development.
Ensure you have the following installed on your machine:
- Node.js
- yarn
- PostgreSQL (optional, can be provisioned via docker)
- Docker
Before setting up the project, you should have the base image for the REPL which includes all the dependencies for each programming language.
cd src/base_images- choose any of the language you want to build for, for example,
to build base image for
c++, cd intocppin the base_images directory and run the following command
docker build -t cpp-base .To build base image for javascript, cd into javascript in the base_images directory and run the following command
docker build -t js-base .To build base image for python, cd into python in the base_images directory and run the following command
docker build -t py-base .- Clone the code from this repository.
- Copy the
.env.examplefile to.env. - Build the project by running
yarn build - Run
make initto setup the database, run migration, copy necessary files and run the project for the first time. - Optional: Run the tests with
yarn test - Run
make runto start the server. - To stop the server, run
ctlr C, then runmake stop-depsto stop the database.
To execute the tests you need to have a postgres database running. Running the database in docker is highly recommended so the tests don't have access to other, unrelated data that may be in a local instance of postgres. If you followed the steps above, the dockerized postgres instance will already be set up. Simply run make start-deps to bring the database up.
- Run
yarn testto run the tests. The tests use theDATABASE_URLdefined in.env - Optional: take down the database with
make stop-deps
- Run
make start-depsto start the database. - Run
make runto start the project. - You can now access the project at
http://localhost:8000.
You can access the database using the DATABASE_URL credentials in the .env file for local development. You can use any DB client of your choice.
After pushing lesson content to master a chapter will remain disabled until a new feature flag is pushed. To unlock a new chapter you must push a feature flag request to the api with the chapter number specified. Here is the necessary scaffold to unlock the next chapter.
curl --location --request PUT '${backend.api}/v1/features/' \
--header 'Origin: http://localhost:3000/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${token}' \
--data '{
"feature_name": "chapter_#_enabled",
"feature_value": 1
}'You can find our Postman workspace here.
TBD