{ "openapi": "3.0.1", "info": { "version": "1.0.0", "title": "API description for powerpulse project", "description": "Routes for api powerpulse" }, "consumes": ["application/json", "multipart/form-data"], "produces": ["application/json", "multipart/form-data"], "servers": [{ "url": "https://power-pulse-fx29.onrender.com/api" }], "tags": [ { "name": "Auth Controllers", "description": "Authorization endpoints" }, { "name": "User Controllers", "description": "User endpoints" }, { "name": "Diary Controllers", "description": "Diary endpoints" }, { "name": "Products Controllers", "description": "Products endpoints" }, { "name": "Exercises Controllers", "description": "Exercises endpoints" } ], "paths": { "/auth/signup": { "post": { "summary": "User registration", "tags": ["Auth Controllers"], "description": "This operation provides users with the ability to register on our website", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserSignUp" } } } }, "responses": { "201": { "description": "You have successfully signed up", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserSignUpResponse" } } } }, "409": { "description": "Email already in use" }, "500": { "description": "Server Error" } } } }, "/auth/signin": { "post": { "summary": "User login", "tags": ["Auth Controllers"], "description": "This operation provides users with the ability to log into their account", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserSignIn" } } } }, "responses": { "201": { "description": "You have successfully logged in", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserSignInResponse" } } } }, "401": { "description": "Email or password is wrong" }, "500": { "description": "Server Error" } } } }, "/auth/logout": { "post": { "summary": "Logout user", "tags": ["Auth Controllers"], "description": "This operation provides users with the ability to log out from their account", "parameters": [ { "in": "header", "name": "Authorization token", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "User successfully logged out" }, "401": { "description": "Missing header with authorization token" }, "500": { "description": "Server Error" } } } }, "/auth/current": { "get": { "summary": "get information about the current user", "tags": ["User Controllers"], "security": [{ "Bearer": [] }], "description": "This operation provides users with the ability to check the current user's information", "parameters": [ { "in": "header", "name": "Authorization token", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Information found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserCurrentResponse" } } } }, "401": { "description": "Missing header with authorization token" }, "500": { "description": "Server Error" } } } }, "/auth/updatedetails": { "post": { "summary": "update user profile information", "tags": ["User Controllers"], "security": [{ "Bearer": [] }], "description": "This operation provides users with the ability to add/update their information", "requestBody": { "required": true, "content": { "multipart/form-data": { "schema": { "$ref": "#/components/schemas/UserUpdateDetails" } } } }, "parameters": [ { "in": "header", "name": "Authorization token", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Calories count", "content": { "multipart/form-data": { "schema": { "$ref": "#/components/schemas/UserUpdateDetailsResponse" } } } }, "401": { "description": "Add at least one new piece of information" }, "500": { "description": "Server Error" } } } }, "/diary/{date}": { "get": { "summary": "Gets User's Diary for specific date", "tags": ["Diary Controllers"], "security": [{ "Bearer": [] }], "parameters": [ { "in": "path", "name": "date", "required": true, "type": "string", "description": "Date in format 11-11-2023" } ], "description": "This operation provides to get diary for a specific date", "requestBody": { "description": "Getting Diary for a specific date object", "required": false, "content": {} }, "responses": { "200": { "description": "You have successfully got the Diary object", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DiaryResponse" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } }, "post": { "summary": "Adds exercise or product into User's Diary", "tags": ["Diary Controllers"], "security": [{ "Bearer": [] }], "description": "This operation provides to add exercise or product to user's diary", "parameters": [ { "in": "path", "name": "date", "required": true, "type": "string", "description": "Date in format 11-11-2023" } ], "requestBody": { "description": "Posting info to Diary object. For posting to array 'consumedProducts' change 'exercise' to 'product' and 'time' to 'amount'", "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AddingToDiary" } } } }, "responses": { "201": { "description": "You have successfully added exercise or product", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DiaryResponse" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } }, "patch": { "summary": "Removes exercise or product from User's Diary", "tags": ["Diary Controllers"], "security": [{ "Bearer": [] }], "parameters": [ { "in": "path", "name": "date", "required": true, "type": "string", "description": "Date in format 11-11-2023" } ], "description": "This operation provides to remove exercise or product from user's diary", "requestBody": { "description": "Updating Diary for a specific date object", "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpdatingDiary" } } } }, "responses": { "200": { "description": "You have successfully got the Diary object", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DiaryResponse" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } } } , "/exercises": { "get": { "summary": "Returns all existing workouts in the database", "tags": ["Exercises Controllers"], "security": [{ "Bearer": [] }], "description": "Returns all existing workouts in the database", "responses": { "201": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Exercises" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } } } , "/products": { "get": { "summary": "Returns all existing product categories in the database", "tags": ["Products Controllers"], "security": [{ "Bearer": [] }], "description": "Returns all existing product categories in the database", "requestBody": { "description": "Getting all existing product categories in the database", "required": false, "content": {} }, "responses": { "201": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Productscategories" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } } } , "/products/byBloodGroup": { "get": { "summary": "Returns to the authorized user all products that are permissible for consumption by their blood type or vice versa", "tags": ["Products Controllers"], "security": [{ "Bearer": [] }], "description": "Returns to the authorized user all products that are permissible for consumption by their blood type or vice versa", "requestBody": { "description": "Getting all products that are permissible for consumption by their blood type or vice versa", "required": false, "content": {} }, "responses": { "201": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProductsgroupBloodNotAllowed" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } } } , "/exercises/type": { "get": { "summary": "Returns all types of body parts, muscles, and equipment existing in the database", "tags": ["Exercises Controllers"], "security": [{ "Bearer": [] }], "description": "Returns all types of body parts, muscles, and equipment existing in the database", "responses": { "201": { "description": "", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ExercisesType" } } } }, "400": { "description": "Bad request (invalid request body)" }, "401": { "description": "Not authorized" }, "404": { "description": "Not found" }, "500": { "description": "Server Error" } } } } }, "components": { "schemas": { "ExercisesType": { "type": "object", "properties": { "_id": { "type": "string", "description": "The unique identifier of the exercise." }, "filter": { "type": "string", "description": "The body part targeted by the exercise." }, "name": { "type": "string", "description": "The equipment used for the exercise." }, "imgURL": { "type": "string", "format": "uri", "description": "The URL of the GIF demonstrating the exercise." } }, "required": ["_id", "imgURL", "name", "filter"] }, "Exercises": { "type": "object", "properties": { "_id": { "type": "string", "description": "The unique identifier of the exercise." }, "bodyPart": { "type": "string", "description": "The body part targeted by the exercise." }, "equipment": { "type": "string", "description": "The equipment used for the exercise." }, "gifUrl": { "type": "string", "format": "uri", "description": "The URL of the GIF demonstrating the exercise." }, "name": { "type": "string", "description": "The name of the exercise." }, "target": { "type": "string", "description": "The specific muscle group targeted by the exercise." }, "burnedCalories": { "type": "integer", "description": "The estimated number of calories burned during the exercise." }, "time": { "type": "integer", "description": "The duration of the exercise in minutes." } }, "required": ["_id", "bodyPart", "equipment", "gifUrl", "name", "target", "burnedCalories", "time"] }, "Productscategories": { "type": "array" }, "ProductsgroupBloodNotAllowed": { "type": "object", "properties": { "_id": { "type": "string", "description": "The unique identifier of the exercise." }, "item":{ "type": "object", "groupBloodNotAllowed":{ "1": { "type": "boolean", "example": "false" }, "2": { "type": "boolean", "example": "false" }, "3": { "type": "boolean", "example": "false" }, "4": { "type": "boolean", "example": "false" } }, "weight":{ "type": "number", "example": 89, "minimum": 35 }, "calories":{ "type": "number", "example": 140, "minimum": 0 } , "category":{ "type": "string", "example": "alcoholic drinks" } }, "allowed":{ "type": "boolean", "example": "false" } } }, "UserSignUp": { "type": "object", "required": ["username", "email", "password"], "properties": { "username": { "type": "string", "example": "Name1235" }, "email": { "type": "string", "example": "example@gmail.com" }, "password": { "type": "string", "example": "pass1234", "minLength": 6 } } }, "UserSignUpResponse": { "type": "object", "properties": { "token": { "type": "string", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1NTNiN2E1ZGRjY2RjMDhiNmJmOWE0YSIsImlhdCI6MTY5OTk4NTMxNywiZXhwIjoxNzAwMDY4MTE3fQ.-dVm-aI4ozwWLhFYMJhirnCVJQLo4itlu3DypPC-5-A" }, "user": { "type": "object", "properties": { "email": { "type": "string", "example": "example@gmail.com" }, "username": { "type": "string", "example": "Name1235" } } }, "message": { "type": "string", "example": "You have successfully signed up" } } }, "UserSignIn": { "type": "object", "required": ["email", "password"], "properties": { "email": { "type": "string", "example": "example@gmail.com" }, "password": { "type": "string", "example": "pass1234" } } }, "UserSignInResponse": { "type": "object", "properties": { "token": { "type": "string", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1NTNiN2E1ZGRjY2RjMDhiNmJmOWE0YSIsImlhdCI6MTY5OTk4NTMxNywiZXhwIjoxNzAwMDY4MTE3fQ.-dVm-aI4ozwWLhFYMJhirnCVJQLo4itlu3DypPC-5-A" }, "user": { "type": "object", "properties": { "email": { "type": "string", "example": "example@gmail.com" } } }, "message": { "type": "string", "example": "You have successfully signed in" } } }, "UserCalories": { "type": "object", "required": ["height", "currentWeight", "birthday", "sex", "levelActivity"], "properties": { "height": { "type": "number", "example": 190, "minimum": 150 }, "currentWeight": { "type": "number", "example": 89, "minimum": 35 }, "birthday": { "type": "number", "example": 23, "minimum": 18 }, "sex": { "type": "string", "example": "male" }, "levelActivity": { "type": "number", "example": 1 } } }, "UserCaloriesResponse": { "type": "object", "properties": { "bmr": { "type": "number", "example": 2384 }, "dailyExerciseTime": { "type": "number", "example": 110 } } }, "UserCurrentResponse": { "type": "object", "properties": { "username": { "type": "string", "example": "Name1235" }, "email": { "type": "string", "example": "example@gmail.com" }, "avatarURL": { "type": "string", "example": "https://res.cloudinary.com/dtuf69cce/image/upload/v1700054125/avatars/dkfism4ftm9g4balgy7x.jpg" }, "height": { "type": "number", "example": 190, "minimum": 150 }, "currentWeight": { "type": "number", "example": 89, "minimum": 35 }, "desiredWeight": { "type": "number", "example": 110, "minimum": 35 }, "birthday": { "type": "number", "example": 23, "minimum": 18 }, "blood": { "type": "number", "example": 3 }, "sex": { "type": "string", "example": "male" }, "levelActivity": { "type": "number", "example": 1 } } }, "UserUpdateDetails": { "type": "object", "properties": { "username": { "type": "string", "example": "Name1235" }, "avatarURL": { "type": "string", "format": "binary" }, "height": { "type": "number", "example": 190, "minimum": 150 }, "currentWeight": { "type": "number", "example": 89, "minimum": 35 }, "desiredWeight": { "type": "number", "example": 110, "minimum": 35 }, "birthday": { "type": "number", "example": 23, "minimum": 18 }, "blood": { "type": "number", "example": 3 }, "sex": { "type": "string", "example": "male" }, "levelActivity": { "type": "number", "example": 1 } } }, "UserUpdateDetailsResponse": { "type": "object", "properties": { "username": { "type": "string", "example": "Name1235" }, "avatarURL": { "type": "string", "example": "https://res.cloudinary.com/dtuf69cce/image/upload/v1700054125/avatars/dkfism4ftm9g4balgy7x.jpg" }, "height": { "type": "number", "example": 190, "minimum": 150 }, "currentWeight": { "type": "number", "example": 89, "minimum": 35 }, "desiredWeight": { "type": "number", "example": 110, "minimum": 35 }, "birthday": { "type": "number", "example": 23, "minimum": 18 }, "blood": { "type": "number", "example": 3 }, "sex": { "type": "string", "example": "male" }, "levelActivity": { "type": "number", "example": 1 } } }, "AddingToDiary": { "type": "object", "oneOf": [ { "properties": { "doneExercises": { "type": "array", "items": { "type": "object", "properties": { "exercise": { "type": "string" }, "time": { "type": "integer" }, "calories": { "type": "integer" } }, "example": { "exercise": "64f2458d6f67bc34bae4f9a9", "time": "180", "calories": "312" }, "required": ["exercise", "time", "calories"] } } }, "required": ["date", "doneExercises"] }, { "properties": { "date": { "type": "string", "format": "date", "example": "11-11-2023" }, "consumedProducts": { "type": "array", "items": { "type": "object", "properties": { "product": { "type": "string" }, "amount": { "type": "integer" }, "calories": { "type": "integer" } }, "example": { "product": "6550c86543e60d02be7da247", "amount": "100", "calories": "337" }, "required": ["product", "amount", "calories"] } } }, "required": ["date", "consumedProducts"] } ] }, "DiaryResponse": { "type": "object", "properties": { "_id": { "type": "string", "example": "6550c426088f7bcbd5c2d456" }, "date": { "type": "string", "format": "date", "example": "11-11-2023" }, "owner": { "type": "string", "example": "6550c426088f7bcbd5c2d321" }, "burnedCalories": { "type": "integer", "example": "312" }, "consumedCalories": { "type": "integer", "example": "337" }, "consumedProducts": { "type": "array", "items": { "type": "object", "properties": { "product": { "type": "object", "properties": { "_id": { "type": "string" }, "title": { "type": "string" }, "category": { "type": "string" } } }, "amount": { "type": "integer" }, "calories": { "type": "integer" }, "groupBloodNotAllowed": { "type": "boolean" }, "_id": { "type": "string" } }, "example": { "product": { "_id": "5d51694902b2373622ff5ec3", "title": "Midori liqueur", "category": "alcoholic drinks" }, "amount": "80", "calories": "337", "groupBloodNotAllowed": "true", "_id": "6550c426088f7bcbd5c2d497" } } }, "doneExercises": { "type": "array", "items": { "type": "object", "properties": { "exercise": { "type": "string", "properties": { "_id": { "type": "string" }, "bodyPart": { "type": "string" }, "equipment": { "type": "string" }, "name": { "type": "string" }, "target": { "type": "string" } } }, "time": { "type": "integer" }, "calories": { "type": "integer" }, "_id": { "type": "string" } }, "example": { "exercise": { "_id": "64f2458d6f67bc34bae4f9a9", "bodyPart": "shoulders", "equipment": "kettlebell", "name": "kettlebell alternating press", "target": "delts" }, "time": "180", "calories": "312", "_id": "6550c426088f7bcbd5c2d497" } } }, "createdAt": { "type": "string", "format": "date", "example": "2023-11-12T14:25:10.867Z" }, "updatedAt": { "type": "string", "format": "date", "example": "2023-11-12T14:25:10.867Z" } } }, "UpdatingDiary": { "type": "object", "required": ["type", "id"], "properties": { "type": { "type": "string", "enum": ["exercise", "product"], "example": "exercise" }, "id": { "type": "string", "example": "64f2458d6f67bc34bae4f9a9" } } } }, "securitySchemes": { "Bearer": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } }