-
Notifications
You must be signed in to change notification settings - Fork 1
API Users
All request must be send with the following headers:
Content-Type: application/json
Some routes are protected with JWT Authentication. To access them, you must obtain a token by login in with a valid user account. More on that, later. Once obtained the token, include it in the following header:
Authorization: Bearer $token
If a token is not passed or invalid, you will get a 401 Unauthorized
response.
On dev mode, the default URL is http://localhost:3000/api
. To start your local server, you can type npm start
in the console. The nodemon included package will execute.
Default URL: http://localhost:3000/api/user
Retrieve a collection of Users.
- name
- surname
- library
Success: 200
,
Error: 500
Retrive a single User.
- name
- surname
- library
- dateOfBirth
- gender
Success: 200
,
Error: 500
Create a new user.
{
email: [email protected]
password: secret
name: Test
surname: Test
dateOfBirth: 2017-02-02
gender: M or F
}
- _id
- message
Success: 201
,
Duplicated email: 409
,
Error: 500
Login with an account.
{
email: [email protected]
password: secret
}
- token
- message
Success: 201
,
Fail auth: 401
,
Error: 500
Update some attributes of an User. Available for the time being: name, surname, dateOfBirth.
{
name: John,
surname: Doe,
dateOfBirth: 1993-12-31
}
- number of attributes modified
- status
- message
Success: 200
,
Error: 500
Add a book to the Author list of books.
- message
Success: 201
,
Error: 500
Remove a book from the Author list of books.
- message
Success: 201
,
Error: 500
Change password of the user, if oldpassword is valid.
{
oldpassword: secret,
newpassword: supersecret
}
- message
Success: 200
,
Error: 500
If the password is incorrect, you will get a 500
status with a message.
Delete an user, if the password is valid.
{
password: secret
}
- message
Success: 200
,
Error: 500
If the password is incorrect, you will get a 500
status with a message.