Git Product home page Git Product logo

city-api's Introduction

city-api

An API for querying an external API which lists users in and nearby a city.

Workings

This solution uses the city endpoint of the supplied API for getting users in the targetted city. It then calls the all users endpoint. Users returned from the first query are excluded from the second query, then the remaining users are iterated through to find those within the specified distance of the target's city central point (using the Haversine formula). The resulting list of users is combined with those returned from the first query to produce all the users in the city and those considered to be nearby.

The solution supplies users with the following endpoint:

GET [host]/api/1.0/people/near/{city}/within/{distance}

This endpoint allows users to supply a city (the solution is currently only configured with latitude/longitude data for "London", currently set as 51.509865, -0.118092) and a distance to consider as being nearby (in miles).

For example, to find all user in or within 50 miles of London the following request would be needed:

GET [host]/api/1.0/people/near/London/within/50

Docs

Dev Commands

The following commands assume you have NodeJs with NPM installed and are to be executed from the project's root directory.

Set up

npm run api:install:dev

Run on dev env

npm run api:start:dev

Generate Docs

npm run api:doc

Generate API Docs

npm run api:apidoc

Lint

npm run api:lint

Test

npm run api:test

Production Commands

Set up

npm run api:install:dev

Build

npm run api:install:dev

Run

Install forever on the server and deploy the build there and run the following command:

npm run forever

city-api's People

Contributors

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