Code Monkey home page Code Monkey logo

http-response-tester's Introduction

http-response-tester

A simple Express app that can respond in various ways useful for testing. It can return a particular status code, it can simulate a network delay (useful for testing latency or timeout scenarios), and it can respond with a pre-configured response body. Licensed under the MIT License.

Usage

Install dependencies:

$ npm install

or

$ yarn

Start application:

$ PORT=3000 npm start # optionally supply port via environment variable (defaults to 3000)

Send a request to the express server:

$ curl -I http://localhost:3000?statusCode={statusCode}

or

$ curl -I http://localhost:3000?delay={delayInSeconds}

Requests can also be composed by supplying multiple query params. Ex:

$ curl -I http://localhost:3000?delay={delayInSeconds}&statusCode={statusCode}

You can now supply configured responses for a given key. The configured responses will be read from an environment variable called HTTP_RESPONSE_TESTER_RESPONSES. They should be formatted standard JSON. To use this feature, send a request like the one below:

$ curl -I http://localhost:3000?body={key}

When 'key' is a key defined in the JSON environment variable, the response will be the value defined in the config for the given key.

Motivation

I decided to develop this little utility because I needed a way to test how an HTTP client would behave with various possible responses.

http-response-tester's People

Contributors

nbbdog11 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

http-response-tester's Issues

upgrade node version

The project is currently pinned to node 9. Should be upgraded to a newer version of node. Target 10.16.3 for now, and then possibly follow up with a newer version after upgrading dependencies to support even newer versions of node.

  • Docker
  • CircleCI
  • NVM

Port that server runs on is hardcoded

The port that the response tester server runs on is currently hardcoded in the code. It should be configurable so that users can specify what port to run on based on system needs. The Dockerfile will also need to be updated because the hardcoded port is exposed there as well.

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.