This is an api endpoint with basic CRUD operations in mongo db collection created with express. It is loosely coupled (dependency injection) server implementation that is the database can be changed in future.
Server: Node, Express, Jsonwebtoken, MongoDb
POST /login
Body | Type | Description |
---|---|---|
username |
string |
Required. (by default jash123) |
password |
string |
Required. (by default jash@1911) |
GET /contacts - token required in Header Authorization Bearer
Query params | Type | Description |
---|---|---|
page |
Number |
Required. for pagination |
POST /add - token required in Header Authorization Bearer
Body | Type | Description |
---|---|---|
contact |
string |
Required. Phone or mobile number |
name |
string |
Required. Name of the person |
POST /findcontact - token required in Header Authorization Bearer
Body | Type | Description |
---|---|---|
contact |
string |
Required. Phone or mobile number |
POST /update - token required in Header Authorization Bearer
Body | Type | Description |
---|---|---|
contact |
string |
Required. Phone or mobile number |
name |
string |
Required. Old name |
newName |
string |
Required. New name |
POST /delete - token required in Header Authorization Bearer
Body | Type | Description |
---|---|---|
contact |
string |
Required. Phone or mobile number |
name |
string |
Required. Name |
takes in contact object, retruns a single contact or null
method to add a contact to database, returns the added contact and its _id
expects pageNumber and pageSize as a parameter
parameters = conatact number and the newName
takes Contact object as input parameter
it needs the exact same Contact object without _id
To run this project, you will need to add the following environment variables to your .env file
ACCESS_TOKEN
- 64 bit hex string
Clone the project
git clone https://github.com/jashjasani/ContactsApi
Go to the project directory
cd my-project
Install dependencies
npm install
Start the server
node server.js