Skip to content

RESTful API for a medieval items store using TypeScript.

Notifications You must be signed in to change notification settings

apoishi/trybe-trybesmith

Repository files navigation

Trybesmith

🇺🇸 English

📃 About

This is the seventh project of the Back-end curriculum developed at Trybe.

In this project I developed a RESTful API for sales of a medieval items store in TypeScript, where it is possible to perform basic operations on a database: Create, Read, Update and Delete. Authentication was done with JSON Web Token.


🚀 Installation

Installing and running with Docker

To run this application you need to have Git, Docker and Docker Compose installed on your computer. Docker Compose needs to be version 1.29 or higher.

1 - Clone the repository:

git clone [email protected]:apoishi/trybe-trybesmith.git

2 - Enter the repository folder you just cloned and use docker-compose to upload the container:

 cd trybe-trybesmith
 docker-compose up -d --build

3 - Run the SQL script to create the database

Connect to the MySQL server running on port 3306, and enter the following credentials:

host: db

user: root

password: password

Go to the MySQL client of your preference, and run the script that is in the Trybesmith.sql file.

4 - Open the trybesmith container terminal.

 docker exec -it trybesmith bash

5 - In the terminal of the container, install the dependencies with the command:

 npm install

6 - Run the application with the command:

 npm run dev
  • I used Thunder Client as a client for HTTP requests and MySQLWorkbench as a MySQL client*

👨‍💻 Skills

  • Declare and use Typescript typings for variables and functions;
  • Use Express with Typescript;

🚂 Routes

Login

POST /login
• If the login was successful, it returns a token to the user.

Order

POST /order
• Register a new order.
GET /order
• Return all orders.

• Validate the token.

Product

POST /product
• Register a new product.
GET /product
• Return all products.

User

POST /user
• Register a new user in the database.

🛠️ Tools

  • Node
  • Express
  • Sequelize
  • Json Web Tokens
  • Joi
  • Docker
  • MySQL
  • TypeScript
🇧🇷 Português

📃 Sobre

Esse é o sétimo projeto desenvolvido na Trybe do módulo de Back-end.

Nesse projeto desenvolvi uma API RESTful de vendas de uma loja de itens medievais em TypeScript, onde é possivel realizar as operações básicas em um banco de dados: Criar, Ler, Atualizar e Deletar (CRUD). A autenticação foi feita com JSON Web Token.


🚀 Instalação e execução

Instalação e execução com Docker

Para rodar esta 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]:apoishi/trybe-trybesmith.git

2 - Entre na pasta do repositório que você acabou de clonar e use o docker-compose para subir o container:

cd trybe-trybesmith   
docker-compose up -d --build

3 - Execute o script SQL para criar o banco de dados

Conecte-se ao servidor MySQL rodando na porta 3306. Utilize as seguintes credenciais:

host: db

user: root

password: password

No cliente MySQL de sua preferência, rode o script que está no arquivo Trybesmith.sql.

4 - Abra o terminal do container trybesmith.

docker exec -it trybesmith bash

5 - No terminal do container, instale as dependências com o comando:

npm install

6 - Execute a aplicação com o comando:

npm run dev
  • Utilizei o Thunder Client como cliente de requisições HTTP e o MySQLWorkbench como cliente MySQL*

👨‍💻 Habilidades

  • Declarar e utilizar as tipagens do Typescript para variáveis e funções;
  • Utilizar Express com Typescript;

🚂 Rotas

Login

POST /login
• Caso o login tenha sido efetuado com sucesso retorna o token para o usuário.

Order

POST /order
• Cadastra um novo pedido.
GET /order
• Retorna todos os pedidos.

• Faz a validação do token.

Product

POST /product
• Cadastra um novo produto.
GET /product
• Retorna todos os produtos.

User

POST /user
• Cadastra um novo usuário no banco de dados.

🛠️ Ferramentas

  • Node
  • Express
  • Sequelize
  • Json Web Tokens
  • Joi
  • Docker
  • MySQL
  • TypeScript

Releases

No releases published

Packages

No packages published