Giter VIP home page Giter VIP logo

compasso_desafio04's Introduction

Challenge 03 - PB NodeJS - Spectrum Squad 🚀

Description

Employee and Product information management API - created using Node.js and MongoDB

Topics

🔹 Info about the project

🔹 How to run the application

🔹 Employee Endpoints

🔹 Product Endpoints


Info about the project 📚

Libs:

Node Version:

v14.16.0

NPM Version:

v6.14.11

...

How to run the application


After cloning the project

 git clone https://github.com/CompassoSP04/compasso_desafio04

Install the dependencies:

 npm install

Config the environment variables (.env)

Inside of the project you have a .env.example file with the required configuration fields:

DB_HOST =
DB_USER =
DB_PASS =
DB_NAME =
DB_PORT =
DB_COLLECTION =


Start the application

 npm start

Employee Endpoints

Create Employee

POST

http://localhost:3000/api/v1/employee/ 

Body Example

{
    "name": "Pedro Barbosa",
    "office": "caixa",
    "cpf": "12345678910",
    "birthday": "02/02/2002"
}

Status Code: 201 Created

{
    "name": "Pedro Barbosa",
    "cpf": "12345678910",
    "office": "caixa",
    "birthday": "2002-02-02T02:00:00.000Z",
    "situation": "active",
    "createdAt": "2022-05-29T22:31:11.307Z",
    "updatedAt": "2022-05-29T22:31:11.307Z",
    "employee_id": "6293f42f1b7e14b9291976a8"
}

Status Code: 400 Bad Request

{
    "message": "Bad Request",
    "details": [
        {
            "message": "error.messsage of the req"
        }
    ]
}

List Employees

GET

http://localhost:3000/api/v1/employee/ 

Res

Status Code: 200 OK

{
    "Employee: [
        {
        "name": "Teste Viera",
        "cpf": "12314512341",
        "office": "gerente",
        "birthday": "2002-02-02T02:00:00.000Z",
        "situation": "active",
        "createdAt": "2022-05-29T21:04:50.182Z",
        "updatedAt": "2022-05-29T21:04:50.182Z",
        "employee_id": "6293dff2cc1337353ec5e8fd"
    },
    {
        "name": "Pedro Barbosa",
        "cpf": "12345678910",
        "office": "caixa",
        "birthday": "2002-02-02T02:00:00.000Z",
        "situation": "active",
        "createdAt": "2022-05-29T22:31:11.307Z",
        "updatedAt": "2022-05-29T22:31:11.307Z",
        "employee_id": "6293f42f1b7e14b9291976a8"
    }
],
    "totalCount": 69,
    "pageSize": 25,
    "totalPages": 3,
    "currentPage": 1
}

List Employee by ID

GET

http://localhost:3000/api/v1/employee/:id

Res

Status Code: 200 OK

{
        {
        "name": "Teste Viera",
        "cpf": "12314512341",
        "office": "gerente",
        "birthday": "2002-02-02T02:00:00.000Z",
        "situation": "active",
        "createdAt": "2022-05-29T21:04:50.182Z",
        "updatedAt": "2022-05-29T21:04:50.182Z",
        "employee_id": "6293dff2cc1337353ec5e8fd"
    }
    
}

Status Code: 400 Bad Request

{
    "message": "Bad Request",
    "details": [
        {
            "message": "error.messsage of the req"
        }
    ]
}

Update Employee

PUT

http://localhost:3000/api/v1/employee/:id 

Body Example

{
    "name": "Leo Guimarães Moraes",
    "cpf": "12309412312",
}

Status Code: 200 OK

{
    "name": "Leo Guimarães Moraes",
    "cpf": "12309412312",
    "office": "caixa",
    "birthday": "2002-02-02T02:00:00.000Z",
    "situation": "active",
    "createdAt": "2022-05-29T22:31:11.307Z",
    "updatedAt": "2022-05-29T22:31:11.307Z",
    "employee_id": "6293f42f1b7e14b9291976a8"
}

Status Code: 400 Bad Request

{
    "message": "Bad Request",
    "details": [
        {
            "message": "error.messsage of the req"
        }
    ]
}

Delete Employee

DELETE

http://localhost:3000/api/v1/employee/:id 

Status Code: 204 No Content

Status Code: 400 Bad Request

{
    "message": "Bad Request",
    "details": [
        {
            "message": "error.messsage of the req"
        }
    ]
}

Product Endpoints

Create Product

POST

http://localhost:3000/api/v1/product/ 

Body Example

{
    "employee_id": "62929f7d355256ca20e19133"
    "name": "Smartphone",
    "category": "eletronico",
    "price": "2500"

}

Status Code: 201 Created

{
    "employee_id": "62929f7d355256ca20e19133"
    "name": "Smartphone",
    "category": "eletronico",
    "price": "2500"
    "product_id: "6293fa9936776ae920fbed22"

}

Status Code: 400 Bad Request

{
    "message": "Bad Request",
    "details": [
        {
            "message": "error.messsage of the req"
        }
    ]
}

List Product

GET

http://localhost:3000/api/v1/product/ 

Body Example

{
    "Product": [
        {
            "employee_id": "629141c268f6ef1d797d39ab",
            "name": "notebook dell",
            "category": "eletronico",
            "price": 3499.99,
            "product_id": "629295758de3cdb4fa87a30a"
        },
        {
            "employee_id": "62929f7d355256ca20e19133"
            "name": "Smartphone",
            "category": "eletronico",
            "price": "2500"
            "product_id: "6293fa9936776ae920fbed22"
        }
    ],
    "totalCount": 290,
    "pageSize": 25,
    "totalPages": 12,
    "currentPage": 1
}



Authors :octocat:

compasso_desafio04's People

Contributors

paulorayann avatar kledsoncr avatar dev-lucasaraujo 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.