-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
All endpoints that require a current user to be logged in.
-
Request: endpoints that require authentication (all)
-
Error Response: Require authentication
-
Status Code: 401
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Authentication required" }
-
All endpoints that require authentication and the current user does not have the correct role(s) or permission(s).
-
Request: endpoints that require proper authorization
-
Error Response: Require proper authorization
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Forbidden" }
-
Returns the information about the current user that is logged in.
-
Require Authentication: true
-
Request
- Method: GET
- URL: /api/auth
- Body: none
-
Successful Response when there is a logged in user
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": { "id": 1, "name": "dani buva", "email": "danibuva@gmail.com", } }
-
-
Successful Response when there is no logged in user
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": null }
-
Logs in a current user with valid credentials and returns the current user's information.
-
Require Authentication: false
-
Request
-
Method: POST
-
URL: /api/auth
-
Headers:
- Content-Type: application/json
-
Body:
{ "email": "danibuva@gmail.com", "password": "password" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": { "id": 1, "name": "dani buva", "email": "danibuva@gmail.com", } }
-
-
Error Response: Invalid credentials
-
Status Code: 401
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Invalid credentials" }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "email": "email required", "password": "password is required" } }
-
Creates a new user, logs them in as the current user, and returns the current user's information.
-
Require Authentication: false
-
Request
-
Method: POST
-
URL: /api/auth
-
Headers:
- Content-Type: application/json
-
Body:
{ "name": "danibuva", "email": "danibuva@gmail.com", "password": "password", "focus": ["work", "friend"] }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "user": { "id": 1, "name": "dani", "email": "danibuva@gmail.com", "focus": ["work", "friend"] } }
-
-
Error response: User already exists with the specified email
-
Status Code: 500
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "user already exists", "errors": { "email": "user with that email already exists" } }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "email": "invalid email", "name": "name is required" } }
-
- all entry endpoints require current user to be logged in and own the entry
Returns all the current user's journal entries.
-
Require Authentication: true
-
Request
- Method: GET
- URL: /api/journey
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "entries": [ { "id": 1, "userId": 1, "sleep": 4, "motivation": 4, "focus": "love", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false } ] }
-
Returns the details of a spot specified by its id.
-
Require Authentication: true
-
Require Authorization: must be the user who owns the morning reflection
-
Request
- Method: GET
- URL: /api/journey/day/:id
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "userId": 1, "sleep": 4, "motivation": 4, "focus": "love", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Error response: Couldn't find a Check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "check in not found" }
-
Returns the details of a spot specified by its id.
-
Require Authentication: true
-
Require Authorization: must be the user who owns the evening reflection
-
Request
- Method: GET
- URL: /api/journey/night/:id
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "userId": 1, "rest": 4, "stress": 4, "productivity": 3, "feeling": "happy", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Error response: Couldn't find a Check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "check in not found" }
-
Returns the details of a spot specified by its id.
-
Require Authentication: true
-
Require Authorization: must be the user who owns the morning reflection
-
Request
- Method: GET
- URL: /api/journey/mood/:id
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "feeling": 4, "description": "calm", "origin": "date", "body": "Why do you think <origin> is making you feel this way? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Error response: Couldn't find a Check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "check in not found" }
-
Creates and returns a new morning check in/ reflection.
-
Require Authentication: true
-
Request
-
Method: POST
-
URL: /api/journey/day
-
Headers:
- Content-Type: application/json
-
Body:
{ "sleep": 3, "motivation": 2, "focus": "Relaxing", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Successful Response
-
Status Code: 201
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "sleep": 4, "motivation": 4, "focus": "love", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "sleep": "sleep is required", "motivation": "motivation is required", "focus": "focus is required", "body": "body is required", "conclusion": "conclusion is required", "prepared": "prepared is required" } }
-
Creates and returns a new evening check in/ reflection.
-
Require Authentication: true
-
Request
-
Method: POST
-
URL: /api/journey/night
-
Headers:
- Content-Type: application/json
-
Body:
{ "rest": 3, "stress": 2, "productivity": 3, "feeling": "Calm", "origin": "Learning", "summary": "I studied a lot today and feel content with the amount I learned. Now I am just chilling.", "prepared": false }
-
-
Successful Response
-
Status Code: 201
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "rest": 3, "stress": 2, "productivity": 3, "feeling": "Calm", "origin": "Learning", "summary": "I studied a lot today and feel content with the amount I learned. Now I am just chilling.", "prepared": false }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "rest": "rest is required", "stress": "stress is required", "productivity": "productivity is required", "feeling": "feeling is required", "origin": "origin is required", "summary": "summary is required", "prepared": "prepared is required" } }
-
Creates and returns a new mood check in/ entry.
-
Require Authentication: true
-
Request
-
Method: POST
-
URL: /api/journey/mood
-
Headers:
- Content-Type: application/json
-
Body:
{ "feeling": 2, "type": "Angry", "origin": "Friends", "body": "My friends don't treat me how I want to be treated :/", "conclusion": "Is there something you need to make amends to? \n <answer>", }
-
-
Successful Response
-
Status Code: 201
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "feeling": 2, "type": "Angry", "origin": "Friends", "body": "My friends don't treat me how I want to be treated :/", "conclusion": "Is there something you need to make amends to? \n <answer>", }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "feeling": "feeling is required", "type": "type is required", "origin": "origin is required", "body": "body is required", "conclusion": "conclusion is required", } }
-
Updates and returns an existing morning reflection.
-
Require Authentication: true
-
Require proper authorization: morning reflection must belong to the current user
-
Request
-
Method: PUT
-
URL: /api/journey/day/:id
-
Headers:
- Content-Type: application/json
-
Body:
{ "sleep": 3, "motivation": 2, "focus": "Relaxing", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "sleep": 4, "motivation": 4, "focus": "love", "body": "How would your day look like, if you were to only do activities that make you feel happy and fulfilled? \n <answer>", "conclusion": "What do you have in life now that you did't have a year ago? \n <answer>", "prepared": false }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "sleep": "sleep is required", "motivation": "motivation is required", "focus": "focus is required", "body": "body is required", "conclusion": "conclusion is required", "prepared": "prepared is required" } }
-
-
Error response: Couldn't find a Morning check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "check in not found" }
-
Updates and returns an existing evening reflection.
-
Require Authentication: true
-
Require proper authorization: evening reflection must belong to the current user
-
Request
-
Method: PUT
-
URL: /api/journey/night/:id
-
Headers:
- Content-Type: application/json
-
Body:
{ "rest": 3, "stress": 2, "productivity": 3, "feeling": "Calm", "origin": "Learning", "summary": "I studied a lot today and feel content with the amount I learned. Now I am just chilling.", "prepared": false }
-
-
Successful Response
-
Status Code: 201
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "rest": 3, "stress": 2, "productivity": 3, "feeling": "Calm", "origin": "Learning", "summary": "I studied a lot today and feel content with the amount I learned. Now I am just chilling.", "prepared": false }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "rest": "rest is required", "stress": "stress is required", "productivity": "productivity is required", "feeling": "feeling is required", "origin": "origin is required", "summary": "summary is required", "prepared": "prepared is required" } }
-
-
Error response: Couldn't find an Evening check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "check in not found" }
-
Updates and returns an existing mood check in.
-
Require Authentication: true
-
Require proper authorization: mood check in must belong to the current user
-
Request
-
Method: PUT
-
URL: /api/journey/mood/:id
-
Headers:
- Content-Type: application/json
-
Body:
{ "feeling": 2, "type": "Angry", "origin": "Friends", "body": "My friends don't treat me how I want to be treated :/", "conclusion": "Is there something you need to make amends to? \n <answer>", }
-
-
Successful Response
-
Status Code: 201
-
Headers:
- Content-Type: application/json
-
Body:
{ "id": 1, "feeling": 2, "type": "Angry", "origin": "Friends", "body": "My friends don't treat me how I want to be treated :/", "conclusion": "Is there something you need to make amends to? \n <answer>", }
-
-
Error Response: Body validation error
-
Status Code: 400
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "feeling": "feeling is required", "type": "type is required", "origin": "origin is required", "body": "body is required", "conclusion": "conclusion is required", } }
-
-
Error response: Couldn't find an Mood check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "check in not found" }
-
Deletes an existing Morning Reflection.
-
Require Authentication: true
-
Require proper authorization: Morning Reflection must belong to the current user
-
Request
- Method: DELETE
- URL: /api/journey/day/:id
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Successfully deleted" }
-
-
Error response: Couldn't find a Check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Check in not found" }
-
Deletes an existing Evening Reflection.
-
Require Authentication: true
-
Require proper authorization: Evening Reflection must belong to the current user
-
Request
- Method: DELETE
- URL: /api/journey/night/:id
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Successfully deleted" }
-
-
Error response: Couldn't find a Check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Check in not found" }
-
Deletes an existing Mood Check in.
-
Require Authentication: true
-
Require proper authorization: Mood check in must belong to the current user
-
Request
- Method: DELETE
- URL: /api/journey/mood/:id
- Body: none
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Successfully deleted" }
-
-
Error response: Couldn't find a Check in with the specified id
-
Status Code: 404
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Check in not found" }
-