Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/raphaelalmeidamartins/store-manager

RESTful API developed with Node.js and Express.js at the end of Unit 23 (Back-end Development Module) of the Trybe's Web Development course
https://github.com/raphaelalmeidamartins/store-manager

chai docker docker-compose expressjs joi-validation mochajs mysql nodejs sinonjs swagger

Last synced: about 12 hours ago
JSON representation

RESTful API developed with Node.js and Express.js at the end of Unit 23 (Back-end Development Module) of the Trybe's Web Development course

Awesome Lists containing this project

README

        

# :shopping_cart: Store Manager :department_store:

![cover](./cover.png)

## :page_with_curl: About/Sobre

:us: English

Node.js and Express.js project developed by [Raphael Martins](https://www.linkedin.com/in/raphaelameidamartins/) at the end of Unit 23 ([Back-end Development Module](https://github.com/raphaelalmeidamartins/trybe_exercicios/tree/main/3_Desenvolvimento-Back-end)) of Trybe's Web Development course. I was approved with 100% of the mandatory and optional requirements met.

We had to create a RESTful API using MSC (Model-Service-Controller) architecture and implement unit tests with Mocha, Chai and Sinon.

:brazil: Português

Projeto Node.js e Express.js desenvolvido por [Raphael Martins](https://www.linkedin.com/in/raphaelameidamartins/) ao final do Bloco 23 ([Módulo Desenvolvimento Back-end](https://github.com/raphaelalmeidamartins/trybe_exercicios/tree/main/3_Desenvolvimento-Back-end)) do curso de Desenvolvimento Web da Trybe. Fui aprovado com 100% dos requisitos obrigatórios e opcionais atingidos.

Tivemos que criar uma API RESTful usando a arquitetura MSC (Model-Service-Controller) e implementar testes unitários com Mocha, Chai e Sinon.

## :man_technologist: Developed Skills/Habilidades Desenvolvidas

:us: English

* Create an Express.js application
* Create a RESTful API using MSC (Model-Service-Controller) architecture
* Validate requests' data with the Joi library
* Implement unit tests with Mocha, Chai and Sinon

:brazil: Português

* Criar uma aplicação Express.js
* Criar uma API RESTful usando arquitetura MSC (Model-Service-Controller)
* Validar dados das requisições com a biblioteca Joi
* Implementar testes unitários com Mocha, Chai e Sinon

## :hammer_and_wrench: Tools/Ferramentas

* Node.js
* Express.js
* Express Rescue
* DotEnv
* Joi
* Mocha.js
* Chai.js
* Sinon.js
* Docker
* MySQL

## :hammer_and_wrench: Installation and execution/Instalação e execução

:us: English

To run this application you need to have **Git**, **Docker** and **Docker Compose** installed on your machine. Docker Compose needs to be at **1.29** version or superior.

### 1 - Clone the repository
```sh
git clone [email protected]:raphaelalmeidamartins/store-manager.git
```

### 2 - Run the containers by running the command below in the application folder
```sh
docker-compose up -d --buid
```

### 3 - Run the SQL Script to create the database

Connect to the MySQL server running on the 3306 port using a MySQL client of your choice. With the following credentials:

* host: `db`
* user: `root`
* password: `password`

Then, in the client, run the scripts in the `migration.sql` and `seed.sql` files.

### 4 - Run this command to attach the container to your terminal
```sh
docker exec -it store_manager bash
```

### 5 - On the attached container, install the dependencies and run the application

Install the dependencies:
```sh
npm install
```

Run the application:
```sh
npm start
```

### 6 - Access the documentation and make requests to the server running on the port 3000

Access the route http://localhost:3000/docs/en to see the English documentation and try the API. If you prefer, you can use a HTTP requests client of your choice (Insomnia, Thunder Client, etc) to make requests.

### 7 - Check the tests coverage by running the following command on the attached terminal
```sh
npm run test:mocha
```

:brazil: Português

Para rodar está aplicação é necessário ter **Git**, **Docker** e o **Docker Compose** instalados no seu computador. O Docker Compose precisa estar na versão **1.29** ou superior.

### 1 - Clone o repositório
```sh
git clone [email protected]:raphaelalmeidamartins/store-manager.git
```

### 2 - Rode os containers executando o comando abaixo na pasta raiz da aplicação
```sh
docker-compose up -d --build
```

### 3 - Execute os scripts SQL para criar o banco de dados

Conecte ao servidor MySQL rodando na porta 3306 usando um cliente MySQL de sua preferência. Utilize as seguintes credenciais:

* host: `db`
* user: `root`
* password: `password`

Então, no cliente, execute os scripts que estão nos arquivos `migration.sql` e `seed.sql`.

### 4 - Rode o comando para abrir o terminal do container store_manager
```sh
docker exec -it store_manager bash
```

### 5 - No terminal do container, installe as dependências e execute a aplicação

Instalando dependências:
```sh
npm install
```

Executando aplicação:
```sh
npm start
```

### 6 - Acesse a documentação e faça requisições para o servidor aberto na porta 3000

Acesse a rota http://localhost:3000/docs/br para acessar a documentação em português e testar a API. Se preferir, utilize um cliente de requisições HTTP de sua preferência (Insomnia, Thunder Client, etc) para fazer as requisições.

### 7 - Rode o seguinte comando no terminal do container para verificar a cobertura dos testes
```sh
npm run test:mocha
```

## :books: Documentation/Documentação

:us: English

With the application running, enter the http://localhost:3000/docs/en route on your browser to see the English documentation.

:brazil: Português

Com a aplicação em execução, acesse a rota http://localhost:3000/docs/br no navegador para ver a documentação em português.

## :test_tube: Tests Coverage/Cobertura de Testes

![Test Coverage - Cobertura dos testes](./test-coverage.png)

## :trophy: Grade/Nota

![My grade of the project - Minha nota no projeto](./nota2.png)