Skip to content

Ljuzifer/healthy-way-backend

Repository files navigation

HEALTY WAY APP

backend

Welcome to the Healthy Way App DARK SIDE!





Getting Started

To get started with the project, follow these steps:

  1. Clone this repository to your local machine:

git clone tap!

  1. Change directory to the project folder:

cd healthy-way-backend

  1. Install the project dependencies:

npm install

  1. Start the development server:

npm run start:dev

  1. Server will start on the http://localhost:3000 or BASE Render URL to access the application.

ROUTES Description:

AUTH:


POST ####/api/auth/registration - new user's registration

req.body:

{
    "name": "Ljuzifer",
    "email": "Ljuzifer@gmail.com",
    "password": "123456",
    "goal": "Gain muscle",
    "gender": "Male",
    "age": 37,
    "height": 188,
    "weight": 100,
    "activityRatio": 1.55
}

POST ####/api/auth/verify - verify new user's email if verification letter doesn't came

req.body:

{
    "email": "email@email.com" - `real email that was registrated`
}

POST ####/api/auth/login - user's login

req.body:

{
    "email": "Ljuzifer@gmail.com",
    "password": "123456"
}

POST ####/api/auth/logout - user's logout

headers.authorization: Bearer accessToken

POST ####/api/auth/refresh - update access & refresh tokens

req.body:

{
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1ODIzY2NhYWUwNjhiMTQwMTZkNTI2MyIsIm5hbWUiOiJManV6aWZlciIsImlhdCI6MTcwMzAzNDE0MywiZXhwIjoxNzA0MTU3MzQzfQ.One4kXthbjqcQpOC5VlZuYxXU9tU7_-WFEqSwCTwd8o"
}

POST ####/api/auth/forgot-password - regenerate user's new password

req.body:

{
    "email": "Ljuzifer@gmail.com"
}

PUT ####/api/auth/change-password - change user's password

headers.authorization: Bearer accessToken

req.body:

{
    "email": "Ljuzifer@gmail.com",
    "password": "123456",
    "newPassword": "654321"
}

DELETE ####/api/auth/delete/:password - deleting user's account

headers.authorization: Bearer accessToken


USER:


GET ####/api/user/current - get user's current information

headers.authorization: Bearer accessToken

PUT ####/api/user/update - update user's information

headers.authorization: Bearer accessToken

req.body:

{
    "name": "Dimon",
    "gender": "Male",
    "age": 37,
    "weight": 108,
    "height": 188,
    "activityRatio": 1.9
} - all not required

POST ####/api/user/load-avatar - upload user's avatar

headers.authorization: Bearer accessToken

form-data: "avatar"

(At cloudinary, the photo is currently being processed and converted to .png)


RECOMMENDED:


GET ####/api/user/recommended-food - get the recommended food

headers.authorization: Bearer accessToken


FOOD (Diary):


GET ####/api/user/food - get user's diary food

headers.authorization: Bearer accessToken

POST ####/api/user/food - add user's diary food

headers.authorization: Bearer accessToken

req.body:

{
    "diary": "Breakfast",
    "name": "ukrainian borshch",
    "carbohydrate": 50,
    "protein": 40,
    "fat": 20,
    "calories": 666
}

PUT ####/api/user/food/:foodId example 657f725654a5a8a137879071 - update diary's food

headers.authorization: Bearer accessToken

req.body: all not required

{
    "diary": "Breakfast",
    "name": "ukrainian borshch",
    "carbohydrate": 50,
    "protein": 40,
    "fat": 20,
    "calories": 666
}

DELETE ####/api/user/food/:foodId example 657f725654a5a8a137879071 - delete diary's food

headers.authorization: Bearer accessToken


GOAL:


PUT ####/api/user/goal - change user's goal

headers.authorization: Bearer accessToken

req.body:

{
    "goal": "Gain muscle"
}

WEIGHT:


PUT ####/api/user/weight - change user's weight

headers.authorization: Bearer accessToken

req.body:

{
    "weight": 88
}

WATER:


GET ####/api/user/water - get user's water level

headers.authorization: Bearer accessToken

PUT ####/api/user/water - update user's water level

headers.authorization: Bearer accessToken

req.body:

{
    "water": 400
}

DELETE ####/api/user/water - reset water level

headers.authorization: Bearer accessToken


STATISTICS:


GET ####/api/user/statistics... - statistics for specific periods

headers.authorization: Bearer accessToken

req.params:

?period=today - for the current day
?period=year - for the current year
?period=month&month=05 - the number of a specific month in the format from 01 to 12 - for the specific month
?period=month&quantity=5 - quantity of months - for a specific number of recent months

Created by © Ljuzifer

LinkedIn Badge