Skip to content

Calculates the cashback amount for each reseller purchase

Notifications You must be signed in to change notification settings

mvibraim/cashback-system

Repository files navigation

CircleCI

Cashback System

Calculates the cashback amount for each purchase from a reseller

Some concepts and technologies used

  • Node.js
  • Express with middleware
  • MongoDB with Mongoose
  • Docker and Docker Compose
  • External request with node-fetch
  • Cursor-based pagination without external library
  • Basic and JWT authentication strategies with Passport
  • Application logs with Winston

Prerequisites

To check if the prerequisites are installed, just use the following commands:

docker -v
docker-compose -v
make -v

Test

Just run npm test

Usage

  1. Run make from root project

  2. Create a reseller

    curl -X POST \
    -d '{
          "email": "marcus@gmail.com",
          "password": "12345678",
          "cpf": "12345678901",
          "full_name": "Marcus"
        }' \
    localhost:3001/resellers
  3. Authenticate as reseller. This will generate a JWT token as response

    curl -X POST --user 12345678901 localhost:3001/resellers/auth

    The password will be prompted

  4. Create a purchase. Replace TOKEN with the token generated in step 3

    curl -X POST -H "Authorization: Bearer TOKEN" \
    -d '{
          "code": "546",
          "data": "2020/04/10",
          "amount": 100000
        }' \
    localhost:3001/resellers/12345678901/purchases
  5. Get purchases. Replace TOKEN with the token generated in step 3

    curl -X GET -H "Authorization: Bearer TOKEN" localhost:3001/resellers/12345678901/purchases

    The query params next and previous can be used to navigate between pages. Default page size is 5

  6. Get cashback amount. Replace TOKEN with the token generated in step 3

    curl -X GET -H "Authorization: Bearer TOKEN" localhost:3001/resellers/12345678901/purchases/cashback

About

Calculates the cashback amount for each reseller purchase

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published