Code Monkey home page Code Monkey logo

challenge-ping-tree's Introduction

This test is to build an API for the http server to receive POST requests with information about a visitor and respond with a decision, either: rejection, or accept with a corresponding target url.

Decisioning

  1. The decisions should be based on information about the visitor that comes in POST request body

     {
         "geoState": "ca",
         "publisher": "abc",
         "timestamp": "2018-07-19T23:28:59.513Z"
     }
    
  2. No target can receive more traffic per day than it allows. Here's an example target with max 10 accepts per day

     {
         "id": "1",
         "url": "http://example.com",
         "value": "0.50",
         "maxAcceptsPerDay": "10",
         "accept": {
             "geoState": {
                 "$in": ["ca", "ny"]
             },
               "hour": {
                 "$in": [ "13", "14", "15" ]
               }
         }
     }
    
  3. All remaining targets should be filtered by criteria they are willing to accept. The above target example only accepts visitors from either California or New York from 13 to 16 UTC.

  4. If no targets are left, the request is rejected (returns {"decision":"reject"}), otherwise it should return the url of the remaining target with the highest value.

Requirements

  1. New endpoints that needs to be built:

    • POST /api/targets
      • post a target
    • GET /api/targets
      • get all targets
    • GET /api/target/:id
      • get a target by id
    • POST /api/target/:id
      • update a target by id
    • POST /route
      • post a request with information about the visitor
      • respond with a decision
  2. API functional tests.

    • each endpoint should have its own test
    • write all tests in test/endpoints.js
    • be sure to understand how servertest works

All persistence should use redis. Source code should be in lib dir. Use redis client factory from lib/redis.js and do not edit this file.

Instructions

How to attempt this test:

  1. Create a new repo in your account and note the git url
  2. Clone this repo
  3. Set your new repo as the origin: git remote set-url origin ${your repo url}
  4. Push your solution to your repo

You must follow these steps for your solution to be accepted -- forks or other methods will not be considered.

challenge-ping-tree's People

Contributors

mian-ali 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.