{"id":18688728,"url":"https://github.com/mian-ali/challenge-ping-tree","last_synced_at":"2026-05-18T03:05:51.778Z","repository":{"id":40463399,"uuid":"489456113","full_name":"mian-ali/challenge-ping-tree","owner":"mian-ali","description":"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.","archived":false,"fork":false,"pushed_at":"2022-05-10T06:52:55.000Z","size":129,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T09:43:51.169Z","etag":null,"topics":["api","api-rest","api-test","challenge","challenge-ping-tree","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mian-ali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-06T18:27:26.000Z","updated_at":"2022-05-06T18:41:10.000Z","dependencies_parsed_at":"2022-08-09T21:12:30.975Z","dependency_job_id":null,"html_url":"https://github.com/mian-ali/challenge-ping-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mian-ali/challenge-ping-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mian-ali%2Fchallenge-ping-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mian-ali%2Fchallenge-ping-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mian-ali%2Fchallenge-ping-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mian-ali%2Fchallenge-ping-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mian-ali","download_url":"https://codeload.github.com/mian-ali/challenge-ping-tree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mian-ali%2Fchallenge-ping-tree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-rest","api-test","challenge","challenge-ping-tree","nodejs"],"created_at":"2024-11-07T10:38:05.233Z","updated_at":"2026-05-18T03:05:51.746Z","avatar_url":"https://github.com/mian-ali.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"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.\n\n## Decisioning\n\n1) The decisions should be based on information about the visitor that comes in POST request body\n \n        {\n            \"geoState\": \"ca\",\n            \"publisher\": \"abc\",\n            \"timestamp\": \"2018-07-19T23:28:59.513Z\"\n        }\n\n2) No `target` can receive more traffic per day than it allows. Here's an example `target` with max 10 accepts per day\n\n        {\n            \"id\": \"1\",\n            \"url\": \"http://example.com\",\n            \"value\": \"0.50\",\n            \"maxAcceptsPerDay\": \"10\",\n            \"accept\": {\n                \"geoState\": {\n                    \"$in\": [\"ca\", \"ny\"]\n                },\n                  \"hour\": {\n                    \"$in\": [ \"13\", \"14\", \"15\" ]\n                  }\n            }\n        }\n\n4) 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.\n\n5) 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.\n\n\n## Requirements\n\n1. New endpoints that needs to be built:\n   - POST /api/targets\n      - post a target\n   - GET /api/targets\n      - get all targets\n   - GET /api/target/:id\n      - get a target by id\n    - POST /api/target/:id\n      - update a target by id\n   - POST /route\n      - post a request with information about the visitor\n      - respond with a decision\n\n2. API functional tests. \n   - each endpoint should have its own test\n   - write all tests in `test/endpoints.js`\n   - be sure to understand how [`servertest`](https://github.com/rvagg/servertest) works\n\n\nAll persistence should use [redis](http://redis.io). \nSource code should be in `lib` dir. \nUse redis client factory from `lib/redis.js` and do not edit this file.\n\n\n## Instructions\n\nHow to attempt this test:\n\n1. Create a new repo in your account and note the git url\n2. Clone this repo\n4. Set your new repo as the origin: `git remote set-url origin ${your repo url}`\n5. Push your solution to your repo\n\nYou must follow these steps for your solution to be accepted -- forks or other methods will not be considered.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmian-ali%2Fchallenge-ping-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmian-ali%2Fchallenge-ping-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmian-ali%2Fchallenge-ping-tree/lists"}