@jaredwray/mockhttp v0.5.0
A simple HTTP server that can be used to mock HTTP responses for testing purposes. Inspired by httpbin and built using nodejs and fastify with the idea of running it via https://mockhttp.org, via docker jaredwray/mockhttp, or nodejs npm install jaredwray/mockhttp.
Features
- All the features of httpbin
@fastify/helmetbuilt in by default- Built with
nodejs,typescript, andfastify - Deploy via
dockerornodejs - Global deployment via mockhttp.org (free service)
- Better API documentation and examples
- Auto detect the port that is not in use
- Maintained and updated regularly!
Deploy via Docker
docker run -d -p 3000:3000 jaredwray/mockhttpDeploy via Docker Compose
services:
mockhttp:
image: jaredwray/mockhttp:latest
ports:
- "3000:3000"If you want to run it on a different port, just change the 3000 to whatever port you want and add in the environment variable PORT to the environment.
services:
mockhttp:
image: jaredwray/mockhttp:latest
ports:
- "3001:3001"
environment:
- PORT=3001You can see an example of this in the docker-compose.yaml file.
Deploy via NodeJS
npm install @jaredwray/mockhttp --savethen run mockhttp in your code.
import { mockhttp } from '@jaredwray/mockhttp';
await mockhttp.start(); // start the server
const response = await fetch('http://localhost:3000/get');
console.log(reaponse);
await mockhttp.stop(); // stop the serverAbout mockhttp.org
mockhttp.org is a free service that runs this codebase and allows you to use it for testing purposes. It is a simple way to mock HTTP responses for testing purposes. It is globally available has some limitations on it to prevent abuse such as requests per second. It is ran via Cloudflare and Google Cloud Run across 7 regions globally and can do millions of requests per second.
Contributing
Please read our CODE OF CONDUCT and CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.