Code Monkey home page Code Monkey logo

cookunity-backend-test's Introduction

CookUnity Backend Api

Intro

A RESTful API which exposes two resources:

  • /traces
  • /statistics

Requirements

/traces

This endpoint will receive, via HTTP POST, an IP address in the format 100.100.100.100, and return the following information associated with that IP address:

  • Country which issued the IP and its ISO code
  • Coordinates for its location (latitude and longitude)
  • An array of currencies for that country with:
  • ISO code (USD, CAD, ARS)
  • Symbol ($, £)
  • Conversion rate from currency to USD
  • Distance between United States and country of origin (in Kilometers)

/statistics

A resource which, on an HTTP GET, returns:

  • Longest distance from requested traces
  • Most traced country

Assumtions

  • For each 3rd party API error, we are returning HTTP CODE 500 - Internal Server Error
  • USA latitude & longitud are from Washigton DC (US Capital)
  • We are using currency name as a symbol instead of currency symbol. ie: Argentinian Peso, not $ symbol.
  • We are only caching GET Symbols endpoint (based on assignment recommendations)
  • We created Docker config for future deploying.
  • We are using config env variables. So, you need to configure them based on .env.sample file.
  • We calculate distance (two point using lat,long) in Kms to USA using a well-known formula searched on Internet.
  • Both resources body repsonses structure are not prettty equal to requested assigment due to GraphQL schema defined.

Installation

$ npm install

Running API

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

Playground GraphQL

http://localhost:3000/graphql

Author

Ignacio Capodanno

cookunity-backend-test's People

Contributors

nachocapodanno avatar

Stargazers

Bima Putra Lamanda avatar

Watchers

James Cloos avatar  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.