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

https://github.com/larissaperinoto/trybesmith-api

The TrybeSmith API consists of a management interface for a medieval products store and was developed using TypeScript.
https://github.com/larissaperinoto/trybesmith-api

docker docker-compose express joi jwt msc mysql nodejs nodemon sql swagger typescript

Last synced: 8 months ago
JSON representation

The TrybeSmith API consists of a management interface for a medieval products store and was developed using TypeScript.

Awesome Lists containing this project

README

          

# TrybeSmith API

[Trybe](https://www.betrybe.com/) is a technology school focused on training Web Developers and the TrybeSmith project was proposed as an activity to improve studies on back-end development with TypeScript.

## Description

The developed application is an API and a database with the content of a medieval articles store. The application must allow creating, reading, updating and removing items from the store's database. It also performs authentication to grant permissions to users when creating new orders.

## Technologies and Tools


mysql
nodejs
docker
express
sequelize
typescript
jwt
Swagger


In the elaboration of the RESTful API, the **Model-Service-Controller(MSC)** architecture was used, in addition to the following tools:

- [TypeScript](https://www.typescriptlang.org/)
- [Node.JS](https://nodejs.org/en/)
- [Express](https://expressjs.com/pt-br/)
- [MySQL](https://www.mysql.com/)
- [Docker](https://www.docker.com/)
- [Sequelize](https://sequelize.org/)
- [JWT](https://jwt.io/)
- [Joi](https://joi.dev/api/)

## ⚙️ How to use

To run the application, start by making a clone of this repository with the command below.

git clone git@github.com:larissaperinoto/trybesmith-api.git

Navigate to the project root.

cd trybesmith-api/

Running locally

Obs: To run the application this way you must have [Node.JS](https://nodejs.org/en/) installed on your machine.



Install the dependencies with the command below.

npm install

Login to MySQL using your local credentials.

mysql -r -p

Logged in the MySQL instance, run the **Trybesmith.sql** script to create the database.

Make a copy of the file **.env.example** with the name **.env** and fill in the information that is necessary to connect with the database.


Information that must be present in the file.env

MYSQL_USER=root
MYSQL_PASSWORD=password
MYSQL_HOST=localhost
JWT_SECRET=secret



Start the application with the command below.

npm start

Running with Docker


Obs: To run the application this way you must have [Docker](https://www.docker.com/) installed on your machine.



In the root of the project, upload the trybesmith and trybesmith_db containers using docker-compose.

docker-compose up -d

Open the trybesmith container terminal.

docker exec -it trybesmith bash

Once in the container terminal, run the command below to install the project's dependencies.

npm install

To connect to the database, open the trybesmith_db container's terminal.

docker exec -it trybesmith_db bash

Login to the database using the credentials described in the docker-compose.yaml file.

mysql -r root -p

Logged in the MySQL instance, run the **Trybesmith.sql** script to create the database.

npm prestart

Start the application with the command below.

npm start

## Routes

You can check all the routes by accessing the /docs endpoint in your browser when running the application.

Routes preview


![Captura de tela de 2022-12-29 15-53-00](https://user-images.githubusercontent.com/98956659/209998561-e55a123f-8cf9-4708-969d-8a6a269daf92.png)

---

Developed by [Larissa Perinoto](www.linkedin.com/in/larissaperinoto), © 2022.