It is a CRUD NodeJS APIs for a typical contact book app with Basic Authentication. It support adding/editing/deleting contacts from a primary storage (MySQL) and allow searching by name and email address.
- In MySQL server create database named contacts_app
CREATE DATABASE contacts_app;
- Go to the project path (.../NodeJS_Contact_Book_Application) in cmd and run this command : node app
- Open browser and browse this url : http://localhost:4000/
- Run the given APIs using Postman or any similar tool.
Get Token for Basic Authentication :
API URL on Localhost : http://localhost:4000/authenticate
API URL on Heroku : https://glacial-meadow-35240.herokuapp.com/authenticate
Method : POST
Input : {"username":"admin","password":"admin"}
Response :
{ "status": "success", "message": "", "totalItems": 1, "start": 0, "end": 0, "items":[ { "message": "User Authenticated!", "token": "access_token" } ] }
Note : Create your own token <access_token> using this API for Basic Authentication for accessing APIs because the token expires in 24 hrs.
API URL on Localhost : http://localhost:4000/_contact/storeContacts
API URL on Heroku : https://glacial-meadow-35240.herokuapp.com/_contact/storeContacts
Method : POST
Input : {"name":"Manvendra","emailId":"manvendra2215@gmail.com"}
Header : {"access-token":"<access_token>"}
API URL on Localhost : http://localhost:4000/_contact/updateContacts
API URL on Heroku : https://glacial-meadow-35240.herokuapp.com/_contact/updateContacts
Method : POST
Input : {"name":"Manvendra","emailId":"manvendra2215@gmail.com"}
Header : {"access-token":"<access_token>"}
API URL on Localhost : http://localhost:4000/_contact/deleteContacts/11
API URL on Heroku : https://glacial-meadow-35240.herokuapp.com/_contact/deleteContacts/11
Method : DELETE
Header : {"access-token":"<access_token>"}
API URL on Localhost : http://localhost:4000/_contact/searchContacts
API URL on Heroku : https://glacial-meadow-35240.herokuapp.com/_contact/searchContacts
Method : POST
Input : {"keyword":"manvendra","limit":"10","offset":"0"}
Header : {"access-token":"<access_token>"}
Note : By Default limit is 10 and offset is 0
- Go to the project path (.../NodeJS_Contact_Book_Application/test) in cmd and run this command : npm test