/FitManager-server

REST API built with NodeJS, TypeScript, Express to the app FitManager

Primary LanguageTypeScriptMIT LicenseMIT

FitManager Server

REST API built with NodeJS, Express and Knex to the app FitManager. This project is part of my portfolio, I'll accept suggestions and criticism. You can use this project as you wish!

Getting Started

Prerequisites

This project was built with NodeJS 14.6, I recommend you use this version or similar.

Installing

Clone the repo

$ git clone https://github.com/nvrsantos/FitManager-server.git
$ cd fitManager-server

Installing dependencies

$ yarn

or

$ npm install

Set settings

  1. Change name of file template_env to .env
  2. Replace <SECRET_KEY> for your of key (anything), change <USER_DB> and <PASSWORD_DB> for credentials of connection of mongodb collection and end chance <EMAIL> and <PASSWORD_EMAIL> for credentials login of your service of email

Running project

In the environment of development execute

$ yarn dev

or

$ npm run dev

In the environment production execute

$ yarn start

or

$ npm run start

Routes

Signin Route

ENDPOINT Method Body URL Params Success Response Server Error Response
/ POST { <email>, <password> } - Code: 200 - OK
Content: { user: {<email>, <password>}, token: <Token JWT> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Signup Route

ENDPOINT Method Body URL Params Success Response Server Error Response
/ POST { <name>, <email>, <password> } - Code: 200 - OK
Content: {message: <A Message Success>}
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Forgot Password Route

ENDPOINT Method Body URL Params Success Response Server Error Response
/ POST { <email> } - Code: 200 - OK
Content: {message: <A Message Success>}
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

User Route

http://localhost:3000/user

ENDPOINT Method Body URL Params Success Response Server Error Response
/ GET - - Code: 200 - OK
Content: { user: {<id>, <name>, <email>, <avatar>}, token: <Token JWT> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/info GET - - Code: 200 - OK
Content: {<weight>, <height>, <IMC>}
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ PUT {<Fields to update>} - Code: 200 - OK
Content: { message: <A Message of success>, token: <Token JWT> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ DELETE - - Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Update Password Route

ENDPOINT Method Body URL Params Success Response Server Error Response
/ PUT { <password>, <newPassword> } - Code: 200 - OK
Content: { user: {<email>, <password>}, token: <Token JWT> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Weight Route

http://localhost:3000/weight

ENDPOINT Method Body URL Params Success Response Server Error Response
/ GET - - Code: 200 - OK
Content: [ {<id>, <title>, <date>}, {<id>, <title>, <date>}, ... ]
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ POST {<title>, <date>} - Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ DELETE - id Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Exercise Route

http://localhost:3000/exercise

ENDPOINT Method Body URL Params Success Response Server Error Response
/ GET - - Code: 200 - OK
Content: [ {<id>, <title>, <day_of_week>, <loop>, <delay_time>}, ... ]
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ POST {<id>, <title>, <day_of_week>, <loop>, <delay_time>} - Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ DELETE - id Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Height Route

http://localhost:3000/height

ENDPOINT Method Body URL Params Success Response Server Error Response
/ GET - - Code: 200 - OK
Content: [ {<id>, <title>, <date>}, {<id>, <title>, <date>}, ... ]
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ POST {<title>, <date>} - Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/ DELETE - id Code: 200 - OK
Content: { message: <A Message of success> }
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Logs Route

http://localhost:3000/logs

ENDPOINT Method Body URL Params Success Response Server Error Response
/error GET - - Code: 200 - OK
Content: <log file>
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/info GET - - Code: 200 - OK
Content: <log file>
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }
/debug GET - - Code: 200 - OK
Content: <log file>
Code: 500 or 400
Content: { error: <A Message with a description of the Error> }

Database Models

User

  • Id - [Integer]
  • Name - [String]
  • Email - [String]
  • Password - [String]
  • Exercises - [Exercise]
  • Weight - [Weight]
  • Height - [Height]

Weight

  • Id - [Integer]
  • Title - [String]
  • Date - [String]
  • User_ID - [Integer]

Height

  • Id - [Integer]
  • Title - [String]
  • Date - [String]
  • User_ID - [Integer]

Exercise

  • Id - [Integer]
  • Title - [String]
  • Day_of_week - [String]
  • Loop - [String]
  • Delay_time - [String]
  • User_ID - [Integer]

Backup

  • Id - [Integer]
  • Data - [Longtext]
  • User_ID - [Integer]

Refresh Token

  • Id - [Integer]
  • Expires_in - [Integer]
  • User_ID - [Integer]

TODO Functions

User Routes

  • - SignUp
  • - SignIn
  • - Forgot Password
  • - Update User
  • - Update Password
  • - Generate backup
  • - Restore backup

App Routes

  • Create New Weight
  • Delete Weight
  • List Weight
  • Create New Height
  • Delete Height
  • List Height
  • Create New Exercise
  • Delete Exercise
  • List Exercise
  • List End Weight, End Height
  • Edit Profile
  • Calculate IMC

Built With

Thanks

This README was based in README