https://github.com/kryptonbd/contact-keeper-api
REST API with Express.Js
https://github.com/kryptonbd/contact-keeper-api
expressjs jwt-authentication nodejs rest-api
Last synced: 9 months ago
JSON representation
REST API with Express.Js
- Host: GitHub
- URL: https://github.com/kryptonbd/contact-keeper-api
- Owner: KryptonBD
- Created: 2021-02-19T09:53:16.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-19T09:53:44.000Z (almost 5 years ago)
- Last Synced: 2025-03-26T13:48:18.827Z (10 months ago)
- Topics: expressjs, jwt-authentication, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Contact Keeper API
This 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.
## Getting Started
Open the config/default.json file and add your **mongoURI** and your **jwtSecret**, than run following commands on bash
```
npm install
npm run server
```
It'll Run on *http://localhost:5000*
# API Usage & Endpoints
## Register a User [POST /api/users]
- Request: Add user and request JSON web token
- Headers
Content-type: application/json
- Body
{
"name": "",
"email": "",
"password": ""
}
- Response: 200 (application/json)
- Body
{
"token": ""
}
## Login with a User [POST /api/auth]
- Request: Login with credentials to recieve a JSON web token
- Headers
Content-type: application/json
- Body
{
"email": "",
"password": ""
}
- Response: 200 (application/json)
- Body
{
"token": ""
}
## Get Contacts [GET /api/contacts]
- Request: Get all contacts of a specific user
- Headers
x-auth-token: YOUR JWT
* Response: 200 (application/json)
- Body
{
"contacts": []
}
## Add New Contact [POST /api/contacts]
- Request: Add a new contact
- Headers
x-auth-token: YOUR JWT
Content-type: application/json
- Body
{
"name": "",
"email": "",
"phone": "",
"type": "" [personal or professional]
}
- Response: 200 (application/json)
- Body
{
"contact": {}
}
## Update Contact [PUT /api/contacts/:id]
- Request: Update existing contact
- Parameters
- id: 1 (number) - An unique identifier of the contact.
- Headers
x-auth-token: YOUR JWT
Content-type: application/json
- Body
{
"name": "",
"email": "",
"phone": "",
"type": "" [personal or professional]
}
- Response: 200 (application/json)
- Body
{
"contact": {}
}
## Delete Contact [DELETE /api/contacts/:id]
- Request: Delete existing contact
- Parameters
- id: 1 (number) - An unique identifier of the contact.
- Headers
x-auth-token: YOUR JWT
* Response: 200 (application/json)
- Body
{
"msg": "Contact removed"
}