Giter Site home page Giter Site logo

steinertruthy / api-sburguer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

Api desenvolvida para a aplicação SBurguer

License: MIT License

Shell 0.80% TypeScript 99.20%
api api-rest sburguer bcrypt expressjs jsonwebtoken nodejs postgresql render typeorm typescript yup

api-sburguer's Introduction

api-SBurguer

GitHub


api-sburguer

Api desenvolvida para a aplicação SBurguer


🛠️ Algumas tecnologias

Esta api foi desenvolvida com as principais tecnologias

  • Node.js
  • Express.js
  • TypeScript
  • Typeorm
  • PostgreSQL
  • Bcrypt
  • Jsonwebtoken
  • Yup

📌 Features

  • Cadastro de usuário
  • Login
  • Listagem de todos os lanches cadastrados
  • Adicionar lanche ao carrinho
  • Remover lanche do carrinho
  • Buscar um lanche específico
  • Pesquisar lanches


📋 Documentação


Cadastro de usuário

  • POST /users

Body

{
  "name": "Steiner",
  "email": "[email protected]",
  "password": "123456"
}

Retorno esperado - 201

{
  "id": "2e4fc5b9-6dde-4726-bf87-5d56c1b05307",
  "email": "[email protected]",
  "name": "Steiner",
}

Possíveis erros

status - 409

{
  "message": "Email already registered"
}

status - 400

{
  "message": [
    "name is a required field",
    "email is a required field",
    "password is a required field"
  ]
}
{
  "message": [
    "password must be at least 6 characters"
  ]
}

Login de usuário

  • POST /login

Body

{
  "email": "[email protected]",
  "password": "1234"
}

Retorno esperado - 200

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InNAbWFpbC5jb20iLCJpYXQiOjE2NzI2MjE2NDksImV4cCI6MTY3Mjc5NDQ0OSwic3ViIjoiZWQ1Mjg5ODQtZTg1Yy00NTY2LWFmNDYtNjU5ZTY5YWI0ZDhjIn0.DPW0nai4FkskWOHxGY-hJWnW8Nt4RxDRgMMxAxNwd70",
  "user": {
  "id": "ed528984-e85c-4566-af46-659e69ab4d8c",
  "email": "[email protected]",
  "name": "Steiner",
  "snacks_cart": [
      {
        "id": "04039c29-7c44-4555-8a03-49cf7c82ca33",
        "name": "Big Burguer",
        "price": "18.00",
        "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/hamb3.png?raw=true",
        "category": "Sanduíches"
      },
      {
        "id": "d402069f-0c01-4c84-81e0-1b3925c097e0",
        "name": "Fanta Guaraná",
        "price": "5.00",
        "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/bebi1.png?raw=true",
        "category": "Bebidas"
      }
    ]
  }
}

Possíveis erros

status - 400

{
  "message": [
    "email is a required field",
    "password is a required field"
  ]
}

status - 401

{
  "message": "Email or password invalid"
}

Buscar todos os lanches

  • GET /snacks

Requer autenticação - Bearer token

{
  headers : {"Authorization": `Bearer ${token}`}
}

Retorno esperado - 200

[
  {
    "id": "0de5f553-29ea-43a3-b16a-df3c03cccbcb",
    "name": "Hamburguer",
    "price": "14.00",
    "category": "Sanduíches",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/hamb1.png?raw=true"
  },
  {
    "id": "af2eefee-6335-4038-9bc0-1bb85a915fcd",
    "name": "X-Burguer",
    "price": "16.00",
    "category": "Sanduíches",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/hamb2.png?raw=true"
  },
  {
    "id": "2767b634-7d85-44ac-bfa3-27dc4accae19",
    "name": "Big Burguer",
    "price": "18.00",
    "category": "Sanduíches",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/hamb3.png?raw=true"
  },
  {
    "id": "b1b35364-6ee5-4839-a90f-a710477999f7",
    "name": "Fanta Guaraná",
    "price": "5.00",
    "category": "Bebidas",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/bebi1.png?raw=true"
  },
  {
    "id": "60f2a3cc-7555-4924-9788-93134c88699d",
    "name": "Coca-Cola",
    "price": "4.99",
    "category": "Bebidas",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/bebi2.png?raw=true"
  }, ...
]

Possíveis erros

status - 401

{
 "message": "Missing header authorization"
}

Adicionar lanche ao carrinho

  • PATCH /cart/${id}

Requer autenticação - Bearer token

{
  headers : {"Authorization": `Bearer ${token}`}
}

Retorno esperado - 204 - No Content

Possíveis erros

status - 401

{
 "message": "Missing header authorization"
}

status - 404

{
 "message": "Snack not found"
}

status - 409

{
  "message": "There is already the some snack in the cart"
}

Remover lanche do carrinho

  • DELETE /cart/${id}

Requer autenticação - Bearer token

{
  headers : {"Authorization": `Bearer ${token}`}
}

Retorno esperado - 204 - No Content

Possíveis erros

status - 401

{
 "message": "Missing header authorization"
}

status - 404

{
 "message": "Snack not found"
}
{
  "message": "Snack not found in the cart"
}

Pesquisar snacks

  • GET /snacks/search/${textSearch} Ex: beb

Requer autenticação - Bearer token

{
  headers : {"Authorization": `Bearer ${token}`}
}

Retorno esperado - 200

[
  {
    "id": "b1b35364-6ee5-4839-a90f-a710477999f7",
    "name": "Fanta Guaraná",
    "price": "5.00",
    "category": "Bebidas",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/bebi1.png?raw=true"
  },
  {
    "id": "60f2a3cc-7555-4924-9788-93134c88699d",
    "name": "Coca-Cola",
    "price": "4.99",
    "category": "Bebidas",
    "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/bebi2.png?raw=true"
  }
]

Possíveis erros

status - 401

{
  "message": "Missing header authorization"
}

Buscar Lanche específico

  • GET /snacks/${id}

Requer autenticação - Bearer token

{
 headers : {"Authorization": `Bearer ${token}`}
}

Retorno esperado - 200

{
  "id": "af2eefee-6335-4038-9bc0-1bb85a915fcd",
  "name": "X-Burguer",
  "price": "16.00",
  "category": "Sanduíches",
  "img": "https://github.com/steinerstt/imgs-projects/blob/main/api-SBurguer/hamb2.png?raw=true"
}

Possíveis erros

status - 401

{
  "message": "Missing header authorization"
}

status - 404

{
  "message": "Snack not found"
}

📄 Licença

Este projeto está sob a licença do MIT - veja o arquivo LICENSE para detalhes.

Feito com ❤ por Steiner

api-sburguer's People

Contributors

steinertruthy 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.