Git Product home page Git Product logo

cars_teste's Introduction


title: 'Api cars Teste' disqus: hackmd

Teste

Table of Contents

[TOC]

Start Project

If you are a total beginner to this, start here!

  1. Download project from git or fork to your git
  2. Open a terminal in the root of the project
  3. Install node in version 18.15.0
  4. Pype in terminal , NPM install to download
  5. Para iniciar o projeto : npm start

Proposta

  • Consumir api externa de carros
  • Enviar Post para API com novos registro
  • Criar um tabela de logs de registro
  • Rota com logs
  • Rota com novos registro mais registro da API
  • Utilizar banco noslq

Rotas

Rota listar Cars

Rota GET http://localhost:5000/api/listCars

Retorna

    [
    {
        "_id": "64bdcec994a4c4001c3e1ac6",
        "title": "Prisma",
        "brand": "VW",
        "price": "900.000.00",
        "age": 2020,
        "__v": 0
    },
    ...
    {
        "_id": "64bdcf0c94a4c4001c3e1ac8",
        "title": "Prisma",
        "brand": "VW",
        "price": "900.000.00",
        "age": 2020,
        "__v": 0
    }
    ]

Rota para cadastro.

Time: 500ms

    {
    "title": "fit",
    "brand": "honda",
    "price": "100000.10",
    "age":"2022"
}

CASO FALHAS

Caso não passe o Title

    {
    "title": "",
    "brand": "honda",
    "price": "100000.10",
    "age":"2022"
}

Retorna

{
    "message": "Obrigatório colocar o Modelo do veiculo"
}

Caso não passe o brand

    {
    "title": "fit",
    "brand": "",
    "price": "100000.10",
    "age":"2022"
}

Retorna

"message": "Obrigatório colocar a Marca do veiculo"

Caso não passe Price

{
    "title": "fit",
    "brand": "honda",
    "price": "",
    "age":"2022"
}

Retorna

{
    "message": "Obrigatório colocar a preço do veiculo"
}

Caso passar letra, simbolos , virgula , cara juntos com números

{
    "title": "fit",
    "brand": "honda",
    "price": "R$100000.10",
    "age":"2022"
}

Retorna

{
    "message": "O campo preço deve ser um número positivo maior que zero, pontos para separar centavos"
}

Caso não passe o age

{
    "title": "fit",
    "brand": "honda",
    "price": "100000.10",
    "age":""
}

Retorne

{
    "message": "O campo data deve conter apenas números"
}

GET Logs

Rota para busca os logs criado

Retorna

{
    "logs": [
        {
            "_id": "64c2bb2cb062cc500cad5382",
            "car_id": "64c2bb2b94a4c4001c3e1ec9",
            "data_hora": "2023-07-27T18:45:00.039Z",
            "createdAt": "2023-07-27T18:45:00.040Z",
            "updatedAt": "2023-07-27T18:45:00.040Z",
            "__v": 0
        },
        {
            "_id": "64c2ba68b062cc500cad537f",
            "car_id": "64c2ba6894a4c4001c3e1ec8",
            "data_hora": "2023-07-27T18:41:44.959Z",
            "createdAt": "2023-07-27T18:41:44.960Z",
            "updatedAt": "2023-07-27T18:41:44.960Z",
            "__v": 0
        }
    ]
}

GET Carros do banco

Rota GET http://localhost:5000/api/CarsDb

Retorna

[
    {
        "_id": "64bdcec994a4c4001c3e1ac6",
        "title": "Prisma",
        "brand": "VW",
        "price": "900.000.00",
        "age": 2020,
        "__v": 0
    }, ...

cars_teste's People

Contributors

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