Code Monkey home page Code Monkey logo

blacksmithing's Introduction

Medieval Store API


Descrição 📜

This is a medieval store API where you can create and read unique items for sale, create and read orders, register and login users.

Built with:


Features 📋

  • Create and read unique items
  • Create and read orders
  • Register and login users
  • Authentication with JWT

Installation 🛠

Installation with Docker 🐳
  1. Clone the repository
git clone [email protected]:lucasdximenes/medieval-store-api.git
  1. Enter the project folder
cd medieval-store-api
  1. You need to have Docker and Docker Compose installed on your machine. If you don't have it, you can download it here and here.

  2. Run the following command to start the containers

docker-compose up -d
  1. Connect to container
docker exec -it trybesmith
  1. Install dependencies and initialize API

In terminal of container

npm install && npm start
  1. The API will be running on port 3000. You can access it by going to http://localhost:3000
Installation without Docker 🌊
  1. Clone the repository
git clone [email protected]:lucasdximenes/medieval-store-api.git
  1. Enter the project folder
cd medieval-store-api
  1. Install the dependencies
npm install
  1. You need to have MySQL installed on your machine. If you don't have it, you can download it here.

  2. Create an .env file in the root of the project and add the following environment variables

MYSQL_USER=YOUR_MYSQL_USER
MYSQL_PASSWORD=YOUR_MYSQL_PASSWORD
MYSQL_HOST=YOUR_MYSQL_HOST
JWT_SECRET=YOUR_JWT_SECRET
  1. Run the migration script in a database manager like DBeaver

migration

  1. Initialize the API
npm start
  1. The API will be running on port 3000. You can access it by going to http://localhost:3000

Documentation 📚

Login route

POST:

  • /login: - Login user

    • Request:

      • {
          "username": "username",
          "password": "password"
        }
    • Response:

      • {
          "token": "token"
        }

Order routes

GET

  • /orders - Get all orders
    • Response:
      • [
          {
            "id": 1,
            "userId": 1,
            "productsIds": [1]
          }
        ]

POST

  • /orders - Create an order

    • Request:

      • Headers:
        • Authorization: Token
      • Body:
        • {
            "userId": 1,
            "productsIds": [1]
          }
    • Response:

      • Body:
        • {
            "userId": 1,
            "productsIds": [1]
          }

Product routes

GET

  • /products - get all products
    • Response:
      • [
          {
            "id": 1,
            "name": "Espada curta",
            "amount": "10 peças de ouro",
            "orderId": 4
          }
        ]

POST

  • /products - Create an product

    • Request:

      • Body:
        • {
            "name": "product name",
            "amount": "product value"
          }
    • Response:

      • Body:

        • {
            "id": 10,
            "name": "product name",
            "amount": "product value"
          }

User routes

POST

  • /users - Register an user

    • Request:

      • Body:
        • {
            "username": "username",
            "vocation": "vocation",
            "level": 999,
            "password": "password"
          }
    • Response:

      • Body:
        • {
            "token": "token"
          }

credits for readme: Lucas Ximenes

blacksmithing's People

Contributors

rodpedrassi avatar trybe-tech-ops avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.