Node.js RESTful API for users/addresses management.
===============
POST - "/users/register"
Content-Type : Application/json
{
email: String,
password: String
}
Status : 201 -> Success / 500 -> Internal Server Error / 403 -> Invalid Data
User : If status == 201, contains the created entity
Error : If status == 500, contains the error message
POST - "/users/authenticate"
Content-Type: Application/json
{
email: String,
password: String
}
Status : 200 -> Success / 500 -> Internal Server Error / 403 -> Invalid Data / 401 -> Wrong Password User : If status == 200, contains the created entity
Token : If status == 200, contains user's JWT Token Error : If status == 500, contains the error message
POST - "/addresses/add"
Content-Type : Application/json
Authorization: JWT token
{
user_id: String,
payload : {
first_name: String,
last_name: String,
address: String
}
}
Status : 201 -> Success / 500 -> Internal Server Error / 401 -> Unauthorized Address: if status == 201, contains the created address record
- Register a user making a POST request to '/users/register'
- Authenticate the user making a POST request to '/users/authenticate'
- Use the obtained JWT Token as 'Authorization' header for POST request to '/addresses/add'
- Use a user's id in the post request's body to save the record in the user's collection
- Enjoy your Address Book!