Giter Club home page Giter Club logo

currency-api's Introduction

Currency API

A simple project to show how to test a Node Express app using MNP - Mocha, Nock and Proxyquire. Code coverage is done with Istanbul (now called nyc). Rewire can be used in place of proxyquire to test private JS methods. This app is a very basic currency API.

Build Status Maintainability Test Coverage

Running app

You can see this app running on Zeit Now, each pull request will have it's own URL.

Run on Google cloud run

Run on Google Cloud

How it works

The GET api works in the following way:

  1. hit URL /api/convert/AUD/USD/2018-07-22.
  2. Checks if the currency exchange rate is in the DB, if yes returns it.
  3. If rate is not in the db it will query the currencyconverterapi.com free API to get the rate.
  4. Returns the rate back and saves it in the DB too.

DB script

To create the db and the table, run the following sql script.

CREATE DATABASE currency CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE TABLE IF NOT EXISTS `currency`.`exchange_rates` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `from_currency` CHAR(3) NOT NULL,
  `to_currency` CHAR(3) NOT NULL,
  `rate` DECIMAL(12,7) NOT NULL,
  `on_date` DATE NOT NULL,
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `rate_on_date_UNIQUE` (`from_currency` ASC, `to_currency` ASC, `on_date` ASC))
ENGINE = InnoDB;

INSERT INTO `currency`.`exchange_rates` (`from_currency`, `to_currency`, `rate`, `on_date`) VALUES ('AUD', 'USD', '0.742719', '2018-07-22');

Configs

Configs for db like username, password etc are in the /src/config.js file.

Run

to run the app you can use docker-compose up the go to http://localhost:8080/api/convert/AUD/USD/2018-07-23 on the browser. It is using the db on remotemysql.com so no need to setup the db locally. If you want to set it up locally change the config in src/configs.js or put in environment variables.

Run tests

To run the tests inside the container run docker-compose run web npm t

To run tests just run npm t to watch test run npm t -- -w.

To watch specific test(s) run npm t -- -w -g "exchangeRates get or even npm t -- -w -g "should use default params if no params are provided and no results in db"

Code coverage

To get the code coverage with Istanbul/nyc execute : npm run test-cov. You should see the code coverage on the cli.

You can also check the code coverage on code climate.

Mutation testing

Has some mutation testing done with Stryker. Current coverage is ~88% with mostly log lines failing. To run the mutation tests run the following after installing stryker.

stryker run

or

npm run mutation-cov

currency-api's People

Contributors

beginci avatar dependabot[bot] avatar geshan avatar ghaleroshan avatar greenkeeper[bot] avatar mmanishh avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

currency-api's Issues

An in-range update of @stryker-mutator/core is breaking the build 🚨

The devDependency @stryker-mutator/core was updated from 2.4.0 to 2.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@stryker-mutator/core is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).
  • ❌ now: Deployment has failed (Details).

Commits

The new version differs by 41 commits.

  • 4324efe v2.5.0
  • 9f591f2 build(deps-dev): force sinon-chai version (#1960)
  • 2074653 build(deps-dev): Bump eslint-plugin-import from 2.19.1 to 2.20.0
  • ca9ae3f build(deps): Bump commander from 4.0.1 to 4.1.0 (#1954)
  • 6254582 build(deps-dev): Bump @types/node from 10.11.7 to 10.17.13
  • 665937d build(deps-dev): Bump install-local from 1.0.0 to 2.0.0 (#1940)
  • e5bda9c build(deps): Bump typed-rest-client from 1.5.0 to 1.7.1 (#1929)
  • b287bde build(deps-dev): Bump karma-jasmine from 2.0.1 to 3.0.1 (#1953)
  • 59b59fb build(deps-dev): Bump @typescript-eslint/eslint-plugin
  • 5dce38a build(deps-dev): Bump @typescript-eslint/parser from 2.14.0 to 2.15.0
  • a690a8a build(deps-dev): Bump @typescript-eslint/parser from 2.13.0 to 2.14.0
  • 6e15cf1 build(deps-dev): Bump eslint-config-prettier from 6.8.0 to 6.9.0
  • 5927a4c build(deps-dev): Bump eslint-config-prettier from 6.7.0 to 6.8.0
  • c1daa87 build(deps-dev): Bump @typescript-eslint/parser from 2.12.0 to 2.13.0
  • 4f6b1e4 build(deps-dev): Bump @typescript-eslint/eslint-plugin

There are 41 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of axios is breaking the build 🚨

The dependency axios was updated from 0.19.0 to 0.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

axios is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).
  • ❌ now: Deployment has failed (Details).

Commits

The new version differs by 47 commits.

  • 960e1c8 Releasing 0.19.1
  • 8a9421d Fixing typo in CHANGELOG.md: s/Functionallity/Functionality (#2639)
  • ee47120 If this place is false, it will report an error, so you should delete the useless code. (#2458)
  • 03e6f4b Fixing invalid agent issue (#1904)
  • dc4bc49 fix: fix ignore set withCredentials false (#2582)
  • 13c948e Remove 'includes' API, fix CI build failure (#2574)
  • fa6cf01 fixing Travis link (#2540)
  • a17c70c Fix CI build failure (#2570)
  • 1a32ca0 Remove dependency on is-buffer (#1816)
  • 0cc22c2 Fix badge, use master branch (#2538)
  • 8414664 Fix XSS logic that matched some valid urls (#2529)
  • bbfd5b1 Adding options typings (#2341)
  • 55aaebc Document fix (#2514)
  • 86d7750 Update docs with no_proxy change, issue #2484 (#2513)
  • b0afbed Adding Typescript HTTP method definition for LINK and UNLINK. (#2444)

There are 47 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @stryker-mutator/mocha-runner is breaking the build 🚨

The devDependency @stryker-mutator/mocha-runner was updated from 2.4.0 to 2.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@stryker-mutator/mocha-runner is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ now: Deployment has failed (Details).
  • ❌ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).

Commits

The new version differs by 41 commits.

  • 4324efe v2.5.0
  • 9f591f2 build(deps-dev): force sinon-chai version (#1960)
  • 2074653 build(deps-dev): Bump eslint-plugin-import from 2.19.1 to 2.20.0
  • ca9ae3f build(deps): Bump commander from 4.0.1 to 4.1.0 (#1954)
  • 6254582 build(deps-dev): Bump @types/node from 10.11.7 to 10.17.13
  • 665937d build(deps-dev): Bump install-local from 1.0.0 to 2.0.0 (#1940)
  • e5bda9c build(deps): Bump typed-rest-client from 1.5.0 to 1.7.1 (#1929)
  • b287bde build(deps-dev): Bump karma-jasmine from 2.0.1 to 3.0.1 (#1953)
  • 59b59fb build(deps-dev): Bump @typescript-eslint/eslint-plugin
  • 5dce38a build(deps-dev): Bump @typescript-eslint/parser from 2.14.0 to 2.15.0
  • a690a8a build(deps-dev): Bump @typescript-eslint/parser from 2.13.0 to 2.14.0
  • 6e15cf1 build(deps-dev): Bump eslint-config-prettier from 6.8.0 to 6.9.0
  • 5927a4c build(deps-dev): Bump eslint-config-prettier from 6.7.0 to 6.8.0
  • c1daa87 build(deps-dev): Bump @typescript-eslint/parser from 2.12.0 to 2.13.0
  • 4f6b1e4 build(deps-dev): Bump @typescript-eslint/eslint-plugin

There are 41 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @stryker-mutator/mocha-framework is breaking the build 🚨

The devDependency @stryker-mutator/mocha-framework was updated from 2.4.0 to 2.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@stryker-mutator/mocha-framework is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).
  • ❌ now: Deployment has failed (Details).

Commits

The new version differs by 41 commits.

  • 4324efe v2.5.0
  • 9f591f2 build(deps-dev): force sinon-chai version (#1960)
  • 2074653 build(deps-dev): Bump eslint-plugin-import from 2.19.1 to 2.20.0
  • ca9ae3f build(deps): Bump commander from 4.0.1 to 4.1.0 (#1954)
  • 6254582 build(deps-dev): Bump @types/node from 10.11.7 to 10.17.13
  • 665937d build(deps-dev): Bump install-local from 1.0.0 to 2.0.0 (#1940)
  • e5bda9c build(deps): Bump typed-rest-client from 1.5.0 to 1.7.1 (#1929)
  • b287bde build(deps-dev): Bump karma-jasmine from 2.0.1 to 3.0.1 (#1953)
  • 59b59fb build(deps-dev): Bump @typescript-eslint/eslint-plugin
  • 5dce38a build(deps-dev): Bump @typescript-eslint/parser from 2.14.0 to 2.15.0
  • a690a8a build(deps-dev): Bump @typescript-eslint/parser from 2.13.0 to 2.14.0
  • 6e15cf1 build(deps-dev): Bump eslint-config-prettier from 6.8.0 to 6.9.0
  • 5927a4c build(deps-dev): Bump eslint-config-prettier from 6.7.0 to 6.8.0
  • c1daa87 build(deps-dev): Bump @typescript-eslint/parser from 2.12.0 to 2.13.0
  • 4f6b1e4 build(deps-dev): Bump @typescript-eslint/eslint-plugin

There are 41 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Use of mutation testing in currency-api - Help needed

Hello there!

My name is Ana. I noted that you use the mutation testing tool StrykerJS in the project.
I am a postdoctoral researcher at the University of Seville (Spain), and my colleagues and I are studying how mutation testing tools are used in practice. With this aim in mind, we have analysed over 3,500 public GitHub repositories using mutation testing tools, including yours! This work has recently been published in a journal paper available at https://link.springer.com/content/pdf/10.1007/s10664-022-10177-8.pdf.

To complete this study, we are asking for your help to understand better how mutation testing is used in practice, please! We would be extremely grateful if you could contribute to this study by answering a brief survey of 21 simple questions (no more than 6 minutes). This is the link to the questionnaire https://forms.gle/FvXNrimWAsJYC1zB9.

We apologize if you have already received message multiple times or if you have already had the opportunity to complete the survey. If you have already shared your feedback, we want to convey our appreciation, kindly disregard this message, and please accept our apologies for any inconvenience.

Drop me an e-mail if you have any questions or comments ([email protected]). Thank you very much in advance!!

An in-range update of @stryker-mutator/javascript-mutator is breaking the build 🚨

The devDependency @stryker-mutator/javascript-mutator was updated from 2.4.0 to 2.5.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@stryker-mutator/javascript-mutator is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).
  • ❌ now: Deployment has failed (Details).

Commits

The new version differs by 41 commits.

  • 4324efe v2.5.0
  • 9f591f2 build(deps-dev): force sinon-chai version (#1960)
  • 2074653 build(deps-dev): Bump eslint-plugin-import from 2.19.1 to 2.20.0
  • ca9ae3f build(deps): Bump commander from 4.0.1 to 4.1.0 (#1954)
  • 6254582 build(deps-dev): Bump @types/node from 10.11.7 to 10.17.13
  • 665937d build(deps-dev): Bump install-local from 1.0.0 to 2.0.0 (#1940)
  • e5bda9c build(deps): Bump typed-rest-client from 1.5.0 to 1.7.1 (#1929)
  • b287bde build(deps-dev): Bump karma-jasmine from 2.0.1 to 3.0.1 (#1953)
  • 59b59fb build(deps-dev): Bump @typescript-eslint/eslint-plugin
  • 5dce38a build(deps-dev): Bump @typescript-eslint/parser from 2.14.0 to 2.15.0
  • a690a8a build(deps-dev): Bump @typescript-eslint/parser from 2.13.0 to 2.14.0
  • 6e15cf1 build(deps-dev): Bump eslint-config-prettier from 6.8.0 to 6.9.0
  • 5927a4c build(deps-dev): Bump eslint-config-prettier from 6.7.0 to 6.8.0
  • c1daa87 build(deps-dev): Bump @typescript-eslint/parser from 2.12.0 to 2.13.0
  • 4f6b1e4 build(deps-dev): Bump @typescript-eslint/eslint-plugin

There are 41 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.