Skip to content

danielnegri/ip-lookup.js

Repository files navigation

Logo

This challenge demonstrates a simple API which purpose is to provide the country name associated with an IP address. The server exposes a lookup endpoint that rely on multiple vendors for redundancy.

Requirements & Capabilities:

  • Given an IP address, return the associated country name

  • Support multiple vendors (ex.: https://ipstack.com/)

  • Naive cache for IP addresses previously requested

  • Global configurable rate limits of the server per vendor per hour

If the rate limit of one vendor has exceeded, the API fallback to other vendor(s). If the result is not in cache and the rate limit is exceeded for all vendors, it returns an error message.

Quick Start

Requirements

# Clone repository
$ git clone https://github.com/danielnegri/ip-lookup.js.git 

# Install dependencies
$ yarn install

# Make sure to edit and include the API keys (dotenv)
$ cp .env.example .env

Running the server in development

$ yarn start

Running the server with Docker (Compose)

$ docker-compose up 

Local Development

# Start (nodemon)
$ yarn dev

# Testing with a random IP
$ curl http://localhost:3000?ip=109.207.79.75
{"country_name":"Israel"}

Testing

# All
$ yarn test

# Unit testing
$ yarn test:unit

# End-to-End
$ yarn test:e2e

Contributing

See CONTRIBUTING for details on submitting patches and the contribution workflow.

License

This repository is under the AGPL 3.0 license. See the LICENSE file for details.

Releases

No releases published

Packages

No packages published