Skip to content

A RESTful API with a single endpoint that fetches the data in a MongoDB collection

Notifications You must be signed in to change notification settings

kenzdozz/getir-challenge

Repository files navigation

getir-challenge

A RESTful API with a single endpoint that fetches the data in a MongoDB collection

Features

  • User can fetch records filtered by startDate, endDate, minCount and maxCount.

API Endpoints

Response codes

Every response has a code which can be one of the following:

  • 0 - Success
  • 400 - Bad request
  • 404 - Not Found
  • 500 - Internal Server Error

Records

  • POST: /records

    • Request Body
      {
        "startDate": "2016-01-21",  // Date 'YYYY-MM-DD`
        "endDate": "2019-01-21",    // Date 'YYYY-MM-DD`
        "minCount": 200,            // number
        "maxCount": 2000            // number
      }
    
    • Sample response
      {
        "code": 0,
        "msg": "Success",
        "records": [
          {
              "key": "TAKwGc6Jr4i8Z487",
              "createdAt": "2017-01-28T01:22:14.398Z",
              "totalCount": 310
          },
          ...
        ]
      }
    

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

What things you need to install the software and how to install them To get the project up and running, you need to have mongodb, nodejs and npm installed on your local machine.

Run the following commands to confirm installations.

node -v
  • should display Node version
npm -v
  • should display npm version
mongo --version
  • should display mongdb version

Installing

  • Clone the repository git clone https://github.com/kenzdozz/getir-challenge.git
  • Navigate to the location of the folder
  • Run npm install to install dependencies
  • Run npm start to get the app started on your local machine

Set Environment Variables

Rename .env.example to .env and update the variables accordingly

Running the tests

To run the tests, run the command

npm run test

The tests, test the api endpoints to ensure that it works and returns the required data.

Built With

  • Nodejs - Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine
  • Express - Fast, unopinionated, minimalist web framework for Node.js
  • MongoDB - MongoDB is a cross-platform document-oriented database program

Authors

License

This project is licensed under the MIT License

About

A RESTful API with a single endpoint that fetches the data in a MongoDB collection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published