npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

api-mock-proxy

v0.2.3

Published

API mocking tool helps developers to work when API is not available

Downloads

15

Readme

Simple API mocking tool

This tool helps developers to continue their task independently of API availability. The developer just needs to route all their API request through this tool and it will cache the response and return mocked response in case of errors.

Uses

  • install api-mock-proxy

    npm install -g api-mock-proxy

  • now you can run your mock proxy as

    api-mock-proxy -p 8000 -t http://your.api.com

    now your proxy server is ready at http://localhost:8000. Just use this URL in all client and you will get the response from http://your.api.com. The best part is, it will return a mocked response if actual API is not working.

Available Options

  • port or -p: (default:8080) - To specify the port to which mock server will listen

  • targetUrl or -t: (default:http://localhost:80) - To specify the target URL where the mock server will forward all requests and return the response back. This will be URL for your actual API and the mock server will save the response for mocking when API responds with an error

  • errorCodes or -e: (default:*) - this will provide options for mocking on errors, error code will be provided in comma separated list like 404,500,ECONNREFUSED. Default value is * which means it will return mocked response for any error unless mode in not record.

  • mode or -m: (default:mix) - It can take any of the three values mock|record|mix

    mock: mock all the request no need to call actual API

    record: always return response from actual API and create a cache for future mocking

    mix: Call the actual API and return actual response except error code passed as mockedError

  • dataPath or -d: (default:./data.json) - path for the mock data, it should be a valid data file. For the first time just specify the path and mock will be created at that location. For running in mock mode there must be pre-populated mock data.

  • --cors - use this to enable cors header for all origin, methods and headers

  • allowOrigin - provide a string to be used in response header 'Access-Control-Allow-Origin'

  • allowMethods - provide a string to be used in response header 'Access-Control-Allow-Methods'

  • allowHeaders - provide a string to be used in response header 'Access-Control-Allow-Headers'

  • sslKey - provide a string to be used as Key for https server, https server will be created only if both key and certificates are provided

  • sslCert - provide a string to be used as Certificate for https server

  • keyFile - provide pat for the Key file to be used for https server

  • certFile - provide pat for Certificate file to be used for https server

Do not use this for data verification or performance testing