Route | HTTP | Header(s) | Body | Description |
---|---|---|---|---|
/api/registerAdmin | POST | none | email: String password: String |
Create a user (role auto admin) success: (201), example: {"_id": String, "email": String, "password": String, "role": String} errors: (500), error |
/api/register | POST | none | email: String password: String |
Create a user (role auto user) success: (201), example: {"_id": String, "email": String, "password": String, "role": String} errors: (500), error |
/api/login | POST | none | email: String password: String |
Login and get token based on credentials success: (200), example: {"_id": String, "email": String, "password": String, "role": String} errors: (400), {msg: 'Invalid email/password'} (500), error |
Route | HTTP | Header(s) | Body | Description |
---|---|---|---|---|
/api/users | GET | Authenticated: (token), Authorized: (role: admin) |
none | Get all users info (Admin only) success: (200), example: [{"_id": String, "email": String, "password": String, "role": String}, {"_id": String, "email": String, "password": String, "role": String}, etc] errors: (500), error |
/api/users/:id | GET | Authenticated: (token) |
none | Get a single user info (Admin and authenticated user) success: (200), example: {"_id": String, "email": String, "password": String, "role": String} errors: (404), example: {msg: 'User not found'} (500), error |
/api/users | POST | Authenticated: (token), Authorized: (role: admin) |
email: String password: String role: String |
Create a user (admin only) success: (201), example: {"_id": String,, "email": String, "password": String, "role": String} errors: (500), error |
/api/users/:id | PUT | Authenticated: (token) |
email: String | Update a user with new info (admin and authenticated user) success: (200), example: {msg: 'Updated'} errors: (404), example: {msg: 'User not found'} (500), error |
/api/users/:id | DELETE | Authenticated: (token), Authorized: (role: admin) |
none | Delete a user (admin only) success: (200), example: {msg: 'Deleted'} errors: (404), example: {msg: 'User not found'} (500), error |
Link Deploy:
https://tranquil-lake-14994.herokuapp.com/
Example:
RegisterAdmin: https://tranquil-lake-14994.herokuapp.com/api/registerAdmin
RegisterMember: https://tranquil-lake-14994.herokuapp.com/api/register
Login: https://tranquil-lake-14994.herokuapp.com/api/login
FindAllMember: https://tranquil-lake-14994.herokuapp.com/api/users
FindOne: https://tranquil-lake-14994.herokuapp.com/api/users/2
Create: https://tranquil-lake-14994.herokuapp.com/api/users
Update: https://tranquil-lake-14994.herokuapp.com/api/users/2
Delete: https://tranquil-lake-14994.herokuapp.com/api/users/2