Fullstack MERN app to manage contacts with React hooks, Context API & JWT authentication.
Install dependencies
npm install
npm client-install
Edit your /config/default.json file to include the correct MongoDB URI
npm run dev # Express & React :3000 & :5000
npm run server # Express API Only :5000
npm run client # React Client Only :3000
Below is a Node/Express/MongoDB REST API for contacts that uses JWT authentication. All contact endpoints are protected and each registered user has their own contacts.
Open the config/default.json file and add your mongoURI and your jwtSecret
npm install
npm run server # Runs on http://localhost:5000
-
Request: Add user and request JSON web token
-
Headers
Content-type: application/json
-
Body
{ "name": "", "email": "", "password": "" }
-
-
Response: 200 (application/json)
-
Body
{ "token": "" }
-
-
Request: Login with credentials to recieve a JSON web token
-
Headers
Content-type: application/json
-
Body
{ "email": "", "password": "" }
-
-
Response: 200 (application/json)
-
Body
{ "token": "" }
-
-
Request: Get all contacts of a specific user
-
Headers
x-auth-token: YOURJWT
-
-
Response: 200 (application/json)
-
Body
{ "contacts": [] }
-
-
Request: Add a new contact
-
Headers
x-auth-token: YOURJWT Content-type: application/json
-
Body
{ "name": "", "email": "", "phone": "", "type": "" [personal or professional] }
-
-
Response: 200 (application/json)
-
Body
{ "contact": {} }
-
-
Request: Update existing contact
-
Parameters
- id: 1 (number) - An unique identifier of the contact.
-
Headers
x-auth-token: YOURJWT Content-type: application/json
-
Body
{ "name": "", "email": "", "phone": "", "type": "" [personal or professional] }
-
-
Response: 200 (application/json)
-
Body
{ "contact": {} }
-
-
Request: Delete existing contact
-
Parameters
- id: 1 (number) - An unique identifier of the contact.
-
Headers
x-auth-token: YOURJWT
-
-
Response: 200 (application/json)
-
Body
{ "msg": "Contact removed" }
-