Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

sachq/challenge-2

Repository files navigation

REST API

Requirements

  • NodeJs
  • TypeScript

Setup

Install all necessary dependencies

$ npm install

Start the server (Development Environment only)

$ npm run dev

Usage

API to do basic CRUD Operations:

  • CREATE

  • READ

  • UPDATE

  • DELETE

  • CREATE

    Create a new Product

    Request URL

    POST /api/products/
    

    Request Object (application/json)

      {
        "id": 1,
        "name": "Transcof",
        "cost": 10.10,
        "currency": "Dollar",
        "appVersion": "0.49",
        "country": "United States"
      }
    

    Response

      {
      "description": "New Product created",
      "content": {
          "name": "Quo Lux 2",
          "cost": 992.52,
          "currency": "Dollar",
          "appVersion": "23.2.3",
          "country": "United States",
          "id": 11
        }
      }
    
  • READ

    Read all Products or get a Product by id

    All Products

    GET /api/products/
    

    For a single Product

    GET /api/products/:id
    

    Request Object (application/json)

      {
        "name": "Transcof",
        "cost": 10.10,
        "currency": "Dollar",
        "appVersion": "0.49",
        "country": "United States"
      }
    

    Response

      [
        {
          "description": "New Product created",
          "content": {
            "id": 11,
            "name": "Transcof",
            "cost": 10.10,
            "currency": "Dollar",
            "appVersion": "0.49",
            "country": "United States"
          }
        },
        ...
      ]
    
  • UPDATE

    Update a single Product, Provide only the necessary fields to update

    All Products

    PATCH /api/products/:id
    

    For a single Product

    GET /api/products/:id
    

    Request Object(application/json)

      {
        "name": "Transcof",
        "cost": 10.10,
        "currency": "Dollar",
        "appVersion": "0.49"
      }
    

    Response

      {
        "description": "Updated Product 1",
        "content": {
          "id": 1,
          "name": "Quo Lux 2",
          "cost": 992.52,
          "currency": "Dollar",
          "appVersion": "23.2.3",
          "country": "United States",
        }
      }
    
  • DELETE

    Delete a single Product

    DELETE /api/products/:id
    

    Response

      {
        "description": "Resource 2 deleted",
        "content": {
          "id": 2
        }
      }
    

About

REST API Coding Test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published