Back-end Technical

Description

This API provides several functions that interact with a user database using Firestore. It has a live url and local installation available, provided you have the correct enviroment variables.

Live URL

https://seahorse-app-mmnsa.ondigitalocean.app

Local Installation

  1. Clone the repository to your local machine:
git clone https://github.com/CyrisXD/Back-end-Technical-Exercise.git
  1. Install the dependencies
npm install
  1. Create your .env file and set up with enviroment variables
Place .env in root folder
Example:

PROJECT_ID=""
PRIVATE_KEY_ID=""
PRIVATE_KEY='""'
CLIENT_EMAIL=""
CLIENT_ID=""
CLIENT_X509_CERT_URL=""
  1. Run the project
npm run dev

Usage

This API contains two endpoints for retrieving and submitting users to the database.

Retrieve all users for testing

Method: GET
Path: /

Retrieve user/s based on surname

CURL
curl -X GET \
  -H "Content-Type: application/json" \
  -d '{"SURNAME": "example"}' \
  https://seahorse-app-mmnsa.ondigitalocean.app/users
HTTPS
Method: GET
Path: /users
body payload
{
    "SURNAME": "example"
}

Submit user to the database

CURL
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"FIRST_NAME": "example", "SURNAME": "example", "EMAIL_ADDRESS": "example@example.com"}' \
  https://seahorse-app-mmnsa.ondigitalocean.app/addusers
HTTPS
Method: POST
Path: /addusers
body payload
{
    "FIRST_NAME": "example",
    "SURNAME": "example",
    "EMAIL_ADDRESS": "example@example.com"
}

Test

Perform the integration test by running the test command:

npm run test