Giter VIP home page Giter VIP logo

test-1's Introduction

Currency Conversion

Version Number: 5b8d0fd276b6d288905ed2f63a934e057e8feca2

Environment

  • Node v14.17.2 (npm v6.14.13)
  • Yarn v1.22.13

This repository uses yarn as the package manager, if you do not have yarn globally installed install it with the command below.

npm install -g yarn

Installation

  • yarn install

Testing

  • yarn run build
  • yarn run test

Running the server

  • yarn run build
  • yarn run server

The server should now be running at port: 3000, should you require a different port please pass a PORT environment.

PORT=8080 yarn run server

Usage

You can get a currency converted with a get request providing the correct query parameters.

All responses are in JSON.

Example 1 - Return the exchange rate from Euro to Dollars

Request:

curl --location --request GET 'http://localhost:3000/rate?fromCurrency=EUR'

Response:

{
    "data": {
        "rate": 1.1387576154415533
    }
}

Example 2 - Convert US dollars to British Pounds

Request:

curl --location --request GET 'http://localhost:3000/convert?fromCurrency=USD&toCurrency=GBP&value=50'

Response:

{
    "data": {
        "value": 39.28,
        "currency": "GBP"
    }
}

Example 3 - Convert Euro to British Pounds

Request:

curl --location --request GET 'http://localhost:3000/convert?fromCurrency=EUR&toCurrency=GBP&value=50'

Response:

{
    "data": {
        "value": 44.74,
        "currency": "GBP"
    }
}

If you fail to provide the required fields, or they are invalid, then you will recieve an error with status code 400.

All responses are in JSON

You can perform an addition using a post request:

Request:

curl --location --request POST 'localhost:3000/convert/addition' \
--header 'Content-Type: application/json' \
--data-raw '{
    "toCurrency": "CAD",
    "values": [
        {
            "currency": "EUR",
            "value": 13.12
        },
        {
            "currency": "GBP",
            "value": 99
        }
    ]
}'

Response:

{
    "data": {
        "currency": "CAD",
        "value": 185.64
    }
}

test-1's People

Contributors

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