Skip to content

Latest commit

 

History

History
102 lines (71 loc) · 4.05 KB

README_en.md

File metadata and controls

102 lines (71 loc) · 4.05 KB

Node Logo Trybe Smith Project Node Logo

🌐 Português Español English Русский 中文 العربية

Application Preview

📜 Description

This is an evaluative project developed in the BackEnd module of the Web Development course at Trybe. The project involved the use of Typescript, Sequelize, and JWT. Throughout the development, various skills were enhanced:

  • Handling tests
  • Using the MSC (Model-Service-Controller) architecture
  • Creating routes for creating, reading, and updating information
  • Route authentication

This project consisted of creating a store for medieval items using Typescript and Sequelize. The main focus was on developing the Service and Controllers layers.

🛠️ Technologies Used

  • Node.js
  • Express
  • Typescript
  • Sequelize
  • MySQL
  • JWT (JSON Web Token)
  • Docker and Docker Compose

📂 Project Structure

The project is structured according to the MSC architecture, where responsibilities are separated among Model, Service, and Controller. Below are some of the main routes implemented:

Routes

  • POST /login: Logs in the user.
  • POST /products: Adds a new product (validates name and price).
  • GET /products: Returns all registered products.
  • GET /orders: Returns all registered orders.
  • POST /orders: Creates a new order (validates JWT, user ID, and product ID).

Middlewares

The project uses several middlewares for validation, including:

  • validateProducts: Validates product data (name and price).
  • validateUser: Validates user data.
  • validateProductById: Validates the existence of the product by ID.
  • validateJWT: Validates the JWT token for authentication.

🚀 Running the Project

To run the project, follow the steps below:

Prerequisites

  • Have Docker and Docker Compose installed.
  • Have Node.js installed (optional, if you want to run locally without Docker).

Steps to Run

  1. Clone the repository:

    git clone https://github.com/seu_usuario/trybe-smith.git
    cd trybe-smith
  2. Create a .env file in the root of the project with the following environment variables:

    DB_USER=root
    DB_PASSWORD=password
    DB_HOST=db
    DB_PORT=3306
    DB_NAME=Trybesmith
    JWT_SECRET=secret
    
  3. Run Docker Compose to build and start the containers:

    docker-compose up --build
  4. Access the API in your browser or API tool (like Postman) at http://localhost:3001.

🔗 Other Projects