GithubHelp home page GithubHelp logo

backend-coding-test's Introduction

Rides Service

Rides service is a service that responsible for rides data. This service provides capabilities such as:

  1. Creating ride data
  2. List and filter ride data
  3. Get single ride data

Setup

Requirements

Installation

  • Install required libraries by executing
    $ npm install
    
  • run test and code coverage. make sure all cases are green and code coverage is above 80% on all aspect
    $ npm run coverage
    
  • run the server
    $ npm start
    $ {"level":"info","message":"App started and listening on port 8010"}
    

Contributing

  • Create new branch from master branch
  • Commit any changes to your branch locally. comply with the linter rules before committing
  • Push your branch into repository. Before push the service will perform npm run coverage automatically. Make sure the test is green and code coverage is above 80&
  • Create your Pull Request. Specify your intent clearly in the description

Load testing

To perform load testing execute command below

$ npm run test:load

API Endpoints

Below is the list of supported API Endpoints of Rides service

Create single ride


Create single ride based on request paramater

[POST] /rides

Request Body

parameter attribute required description
start_lat float required represent latitude starting point of ride
start_long float required represent longitude starting point of ride
end_lat float required represents latitude ending point of ride
end_long float required represents longitude ending point of ride
rider_name string required represents rider name
driver_name string required represents driver name
driver_vehicle string required represents driver vehicle

Sample Request

  curl --request POST \
    --url http://localhost:8010/rides \
    --header 'Content-Type: application/json' \
    --data '{
        "start_lat": 80,
        "start_long": 100,
        "end_lat": 81,
        "end_long": 101,
        "rider_name": "Sugiharto",
        "driver_name": "Sugeng",
        "driver_vehicle": "Motorcycle"
  }'

SampleResponse

  • Response Code: 200

    [
      {
        "rideID": 1,
        "startLat": 80,
        "startLong": 100,
        "endLat": 81,
        "endLong": 101,
        "riderName": "Sugiharto",
        "driverName": "Sugeng",
        "driverVehicle": "Motorcycle",
        "created": "2022-06-16 12:04:49"
      }
    ]
    
  • Response Code: 400

    {
      "error_code": "VALIDATION_ERROR",
      "message": "Start latitude and longitude must be between -90 - 90 and -180 to 180 degrees respectively"
    }
    

List rides


List created rides data

[GET] /rides?offset={offset}&limit={limit}

Request Parameter

parameter attribute required description
offset integer optional Offset of pagination. if not specified, default value is 0
limit integer optional Result limit. Default value is 10

Sample Request

curl --request GET \
  --url http://localhost:8010/rides

SampleResponse

  • Response Code: 200

    [
      {
        "rideID": 1,
        "startLat": 80,
        "startLong": 100,
        "endLat": 81,
        "endLong": 101,
        "riderName": "Sugiharto",
        "driverName": "Sugeng",
        "driverVehicle": "Motorcycle",
        "created": "2022-06-16 12:04:49"
      }
    ]
    
  • Response Code: 404

    {
      "error_code": "RIDES_NOT_FOUND_ERROR",
      "message": "Could not find any rides"
    }
    

Get ride detail by id


Get single ride data by id

[GET] /rides/:id

Path Parameter

parameter attribute required description
id integer required Represents id of single ride

Sample Request

curl --request GET \
  --url http://localhost:8010/rides/1

SampleResponse

  • Response Code: 200

    [
      {
        "rideID": 1,
        "startLat": 80,
        "startLong": 100,
        "endLat": 81,
        "endLong": 101,
        "riderName": "Sugiharto",
        "driverName": "Sugeng",
        "driverVehicle": "Motorcycle",
        "created": "2022-06-16 12:04:49"
      }
    ]
    
  • Response Code: 404

    {
      "error_code": "RIDES_NOT_FOUND_ERROR",
      "message": "Could not find any rides"
    }
    

backend-coding-test's People

Contributors

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