JustJava API
Backend API for JustJava-Android, a mock food ordering and delivery application for a coffee shop.
Latest development: https://dev.justjava.store/
Latest release: https://api.justjava.store/
Prerequisites
PostgreSQL
Used to store the API's data.
- Create a PostgreSQL database
- Get the url in the form
postgres://username:password@host:port/database
Redis
Used to store sessions.
- Create a Redis instance
- Get the url in the form
redis://:password@host:port/0
Firebase
Used for notifications.
- Create a project on the Firebase console
- Create and download a service account key
- Upload it to a public url.
GCP Project (optional)
Used for Google Sign In and uploading product images.
- Create a project on GCP.
- Take note of the project id.
- Create OAuth client ID credentials with "Web Application" as the application type.
- Take note of the client ID.
- Create a bucket on Cloud Storage
Safaricom Developer Account (optional)
Used for M-Pesa payments
- Create an account on Daraja.
- Create an app.
- Get the
consumerKey
andconsumeSecret
.
JustJava worker (optional)
Used to automatically update the order status when a payment has been completed.
- Clone the repository MarkNjunge/justjava-worker
- Follow installation instructions.
Datadog (optional)
Used for logs
Ravepay Sandbox Account (optional)
Used for card payments
-
Create an account and business on Ravepay sandbox
-
Go to API settings and get the pubnlic key and secret key.
Mailgun (optional)
Used for sending password reset emails. If this is disabled, the token will be returning in the HTTP response.
-
Create an account on Mailgun and complete the setup.
-
Create an email template called
reset-password
that has aname
andtoken
parameter.
Installation
- Clone the repository
$ git clone https://github.com/MarkNjunge/justjava-api.git
- Make a
./config/local.json
file based on./config/default.json
.
Alternatively, make a.env
file. See environment variable mappings in custom-environment-variables.json.
$ cp ./config/default.json ./config/local.json
- Install dependencies
$ yarn install
- Start the server
$ yarn run start
# watch mode
$ yarn run start:dev
- Go to
/docs
to view routes documentation.
Docker
Build docker images
docker build -t justjava-api .
or use docker-compose
docker-compose up -d
Testing
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov