Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
/ justjava-api Public archive
generated from MarkNjunge/nest-boilerplate

Backend for a mock food ordering and delivery application for a coffee shop

License

Notifications You must be signed in to change notification settings

MarkNjunge/justjava-api

Repository files navigation

JustJava API

Known Vulnerabilities

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.

  1. Create a PostgreSQL database
  2. Get the url in the form postgres://username:password@host:port/database

Redis

Used to store sessions.

  1. Create a Redis instance
  2. Get the url in the form redis://:password@host:port/0

Firebase

Used for notifications.

  1. Create a project on the Firebase console
  2. Create and download a service account key
  3. Upload it to a public url.

GCP Project (optional)

Used for Google Sign In and uploading product images.

  1. Create a project on GCP.
  2. Take note of the project id.
  3. Create OAuth client ID credentials with "Web Application" as the application type.
  4. Take note of the client ID.
  5. Create a bucket on Cloud Storage

Safaricom Developer Account (optional)

Used for M-Pesa payments

  1. Create an account on Daraja.
  2. Create an app.
  3. Get the consumerKey and consumeSecret.

JustJava worker (optional)

Used to automatically update the order status when a payment has been completed.

  1. Clone the repository MarkNjunge/justjava-worker
  2. Follow installation instructions.

Datadog (optional)

Used for logs

  1. Create an account on Datadog
  2. Create an API key

Ravepay Sandbox Account (optional)

Used for card payments

  1. Create an account and business on Ravepay sandbox

  2. 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.

  1. Create an account on Mailgun and complete the setup.

  2. Create an email template called reset-password that has a name and token parameter.

Installation

  1. Clone the repository
$ git clone https://github.com/MarkNjunge/justjava-api.git
  1. 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
  1. Install dependencies
$ yarn install
  1. Start the server
$ yarn run start

# watch mode
$ yarn run start:dev
  1. Go to /docs to view routes documentation.

http://localhost:3000/docs

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