A collection of REST API endpoints that exposes methods that allows contacts of a system the ability to referral people to the system
This project was built with the following:
- Node LTS version - v8.9.0
- NPM - v6.2.0
- Postgres - v10.3
- Clone the repo and cd into the folder:
git clone git@github.com:ruqoyyasadiq/referral-system-api.git && cd referral-system-api
- Rename
env.sample
as.env
and set the contained values appropriate.
Note: The value
REFERRAL_POINTS
is set as an environment variable, to provide flexiblity of points assigned to referrer. For the sake of this project's requirement, the value ofREFERRAL_POINTS
should be left at 100 as set in the sample file. In subsequent versions, depending on the possibility of having multiple, different types of points, we should have a static table in the database that stores these points values.
- Install Project dependencies
npm install
- Ensure Postgres services is running. Click here to view setup for Mac OS users
- Create DB
npm run db:create
- Start the app in development with:
npm run dev
or in non-dev mode with:
npm start
- Run Database migrations
npm run db:migrate
- Seed Database with Contact Details
npm run db:seed
- Access the server via:
http://localhost:5000/v1/{resourceName}
- To run the application test, begin by creating a test DB with:
createdb {test_db_name}
where test_db_name
is TEST_DB
as specified in .env
file
- Run test via npm scripts with command
npm test
or
npm t
Endpoint Description | Routes | Method |
---|---|---|
Fetch all Contacts | /v1/contacts | GET |
Fetch Leaderboard | /v1/contacts/leaderboard | GET |
Fetch Single Contact | /v1/contacts/:contactId | GET |
Update Single Contact | /v1/contacts/:contactId | PUT |
Update Single Contact | /v1/referrals/new | POST |
- Paginate lists - Contacts and Leaderboard list
- Implement actual
SlackNotifier
for referral creation - Refactor Referral Controller
- Increase Test Coverage
- Set up static table for points. Assumptions made is: down the line there would be multiple types of points for (possibly) different kinds/levels of referrals. This should live in the DB