Giter Club home page Giter Club logo

nestultra's Introduction

Build Status

Ultra task

Prerequisites

  • The only one is have docker installed and being logged in to be able to pull the images.

Build the containers

To build the containers you just need to clone the repo and open a terminal inside the directory, then just build the containers with:

docker-compose up

Usage

First

Please make a POST request to the endopint:

http://localhost:3700/trigger/populate

In order to populate the database with example data needed in postman.

Port and url

The port exposed port of the Nest application is 3700, so to test the API calls should be done to that port, you can see the default index view your browser at: http://localhost:3700.

All the requests related to this task should be done at http://localhost:3700/cars.

Unittests

If you already have the containers running, the tests are run just with:

docker exec -it nest_worker npm test

Remove

To remove the containers, the volume and the network just run:

docker-compose down -v

Endpoints

GET

resource description
/cars returns a list of all the cars and his relations.
/cars/{car_id} returns a car description with his relations.
/cars/{car_id}/manufacturer returns a manufacturer description for the given car.
/trigger Trigger a process which will automatically remove the owners who bought their cars before the last 18 months and apply a discount of 20% to all cars having a date of first registration between 12 and 18 months.

POST

resource description
/cars Inserts a car in the database, if the owners and manufacturer id alredady exists it associates with them, if not, they are created firstRegistrationDate is optional.
/trigger/populate Special endpoint that adds an example to the database, should be reached just once.

PUT

resource description
/cars/{car_id} Updates a car value in the db, it doesn't change the values in owners or manufacturer but if another id that exists is sended it changes the relationships.

DELETE

resource description
/cars/{car_id} Deletes a car value in the db.

Postman collection

You can test the API with the postman collection that have some requests preload with the example values added with the trigger endpoint.

To use it just import the file ultra_task.postman_collection.json with the postman option.

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.