Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mariosantosdev/fitmanager-server

REST API built with NodeJS, TypeScript, Express to the app FitManager
https://github.com/mariosantosdev/fitmanager-server

bcryptjs cors dayjs docker-compose express fit fitness fitness-app jsonwebtoken nodejs nodemailer postgresql prisma typescript

Last synced: 5 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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 `` for your of key (anything), change `` and `` for credentials of connection of mongodb collection and end chance `` and `` 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

- **This is the route that you can use to signin**
> http://localhost:3000/signin

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | ------ | ------------------------- | ---------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| / | `POST` | `{ , }` | - | **Code:** 200 - OK
**Content:** `{ user: {, }, token: }` | **Code:** 500 _or_ 400
**Content:** `{ error: }` |

#### Signup Route

- **This is the route that you can use to create a new user**
> http://localhost:3000/signup

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | ------ | --------------------------------- | ---------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| / | `POST` | `{ , , }` | - | **Code:** 200 - OK
**Content:** `{message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### Forgot Password Route

- **This is the route that you can use to generate a new password and send to your email**
> http://localhost:3000/forgot

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | ------ | ------------- | ---------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| / | `POST` | `{ }` | - | **Code:** 200 - OK
**Content:** `{message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### User Route

> http://localhost:3000/user

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | -------- | ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| / | `GET` | - | - | **Code:** 200 - OK
**Content:** `{ user: {, , , }, token: }` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| /info | `GET` | - | - | **Code:** 200 - OK
**Content:** `{, , }` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `PUT` | `{}` | - | **Code:** 200 - OK
**Content:** `{ message:
, token: }` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `DELETE` | - | - | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### Update Password Route

- **This is the route that you can update your password**
> http://localhost:3000/user/password

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | ------ | ------------------------------- | ---------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| / | `PUT` | `{ , }` | - | **Code:** 200 - OK
**Content:** `{ user: {, }, token: }` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### Weight Route

> http://localhost:3000/weight

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | -------- | ------------------- | ---------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| / | `GET` | - | - | **Code:** 200 - OK
**Content:** `[ {, , }, {, , }, ... ]` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `POST` | `{, }` | - | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `DELETE` | - | id | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### Exercise Route

> http://localhost:3000/exercise

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | -------- | ------------------------------------------------------ | ---------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| / | `GET` | - | - | **Code:** 200 - OK
**Content:** `[ {, , , , }, ... ]` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `POST` | `{, , , , }` | - | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `DELETE` | - | id | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### Height Route

> http://localhost:3000/height

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | -------- | ------------------- | ---------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| / | `GET` | - | - | **Code:** 200 - OK
**Content:** `[ {, , }, {, , }, ... ]` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `POST` | `{, }` | - | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| / | `DELETE` | - | id | **Code:** 200 - OK
**Content:** `{ message:
}` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |

#### Logs Route

> http://localhost:3000/logs

| ENDPOINT | Method | Body | URL Params | Success Response | Server Error Response |
| -------- | ------ | ---- | ---------- | ------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| /error | `GET` | - | - | **Code:** 200 - OK
**Content:** `` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| /info | `GET` | - | - | **Code:** 200 - OK
**Content:** `` | **Code:** 500 _or_ 400
**Content:** `{ error:
}` |
| /debug | `GET` | - | - | **Code:** 200 - OK
**Content:** `` | **Code:** 500 _or_ 400
**Content:** `{ 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

- [x] - SignUp
- [x] - SignIn
- [x] - Forgot Password
- [x] - Update User
- [x] - Update Password
- [ ] - Generate backup
- [ ] - Restore backup

### App Routes

- [x] Create New Weight
- [x] Delete Weight
- [x] List Weight
- [x] Create New Height
- [x] Delete Height
- [x] List Height
- [x] Create New Exercise
- [x] Delete Exercise
- [x] List Exercise
- [x] List End Weight, End Height
- [x] Edit Profile
- [x] Calculate IMC

## Built With

- [NodeJS](https://nodejs.org/en/) - Build the project
- [TypeScript](https://www.typescriptlang.org/) - Language that Build the project
- [express](https://expressjs.com/) - Router of the Application
- [bcryptjs](https://github.com/dcodeIO/bcrypt.js) - Module for encode the password in a hash
- [cors](https://github.com/expressjs/cors) - Middleware for provide connection
- [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) - Encode and Decode JWT
- [dayJS](https://day.js.org/) - Parsing, validating, manipulating, and formatting dates
- [nodemailer](https://nodemailer.com/) - Module for send email
- [prisma](https://prisma.io) - Database ORM
- [postgresql](https://www.postgresql.org/) - Database
- [docker-compose](https://docs.docker.com/compose/) - DevOps Database virtual environment

## Thanks

This README was based in [README](https://github.com/steniowagner/mindcast-server/blob/master/README.md)