-
Knex Configurations / Commands
- knex init
- knex migrate:make initial
- inside: data/dbConfig.js change development to production when ready to deploy
-
Authentication Configurations
- Change: config.js secret: before deploying final.
- Navigate to /register
- Provide a user object following this template:
{
"email": "[email protected]",
"password": "1234"
}
- Server will return the following object if successful:
{ "message": "success" }
- Server will return the following error if unsuccessful:
{
"errorMessage": "unable to register user. Already registered? Try to log-in instead!"
}
- Navigate to /login
- Provide a user object following this template:
{
"email": "[email protected]",
"password": "1234"
}
- Server will return an object like this one if successful:
{
"id": 7,
"email": "[email protected]",
"auth": true,
"createdAt": "2018-02-13 19:40:33",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTg1NTQ5NjAsImRhdGEiOiJ0ZXN0QGVtYWlsLmNvbSIsImlhdCI6MTUxODU1MTM2MH0.ijuolir7q2nkMa50Td6JLNLqfkdmUn7t7tuh89oEb_M"
}
- Server will return this error if unsuccessful:
{
"errorMessage": "User not Authenticated, Please log-in again!"
}
- Navigate to /users
- Provide a JWT with the token that was given when the user logged in in the headers Authorization.
- A list of users will be returned.
- Server will return this error if unsuccessful:
{
"error": "Token invalid, please login",
"message": {
"name": "JsonWebTokenError",
"message": "invalid signature"
}
}
- Navigate to /users
- Provide a user object like the one bellow:
{
"email": "[email protected]",
"password": "1234"
}
- Server will return 1 if the user was deleted successfully.
- Server will return an error if it was unable to delete the user.
- Navigate to /update
- Provide a user object like the one bellow.
{
"email": "[email protected]",
"password": "1234",
"newPassword": "4321",
}
- Server will return 1 if the user was updated successfully.
- Server will return an error if it was unable to update the newPassword, or was unable to authenticate with the provided password.