store_manager
:shopping_cart:🏬partment_store:
📃 About/Sobre
:us: English
Node.js and Express.js project developed by Gustavo da Silva at the end of Unit 23 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 Gustavo da Silva ao final do Bloco 23 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
🛠️ Tools/Ferramentas
- Node.js
- Express.js
- Express Rescue
- DotEnv
- Joi
- Mocha.js
- Chai.js
- Sinon.js
- Docker
- MySQL
🛠️ 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
git clone [email protected]:GusttavoCDN/store_manager.git
2 - Run the containers by running the command below in the application folder
docker-compose up -d
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
docker exec -it store_manager bash
5 - On the attached container, install the dependencies and run the application
Install the dependencies:
npm install
Run the application:
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
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
git clone [email protected]:raphaelalmeidamartins/store-manager.git
2 - Rode os containers executando o comando abaixo na pasta raiz da aplicação
docker-compose up -d
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
docker exec -it store_manager bash
5 - No terminal do container, installe as dependências e execute a aplicação
Instalando dependências:
npm install
Executando aplicação:
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
npm run test:mocha
📚 Documentation/Documentação
:us: English
With the application running, enter the http://localhost:3000/docs route on your browser to see Documentation and try the API.
:brazil: Português
Com a aplicação em execução, acesse a rota http://localhost:3000/docs no navegador para ver a documentação.