http-418
v0.1.0
Published
I'm a Teapot π« β Mock any HTTP status code instantly
Downloads
84
Maintainers
Readme
What?
Need a server that returns 404? 500? 418 I'm a Teapot?
npx 418 404That's it. A server is now running on localhost:4180, returning 404 Not Found to every request. Every method, every path, every time.
Why?
Because when you're testing error handling in your frontend, API client, or webhook β you don't want to write a whole server. You want to type one command and get back to work.
Install
# Just use it (no install needed)
npx 418
# Or install globally
npm install -g 418Usage
# Default: the legendary 418 I'm a Teapot
npx 418
# Any status code
npx 418 404
npx 418 500
npx 418 204
# Custom port
npx 418 503 -p 3000
# List all HTTP status codes
npx 418 -l
# List only 4xx codes
npx 418 -l 4xxWhat you'll see
;,'
_,-'/ )
.-' ' .-' π« 418 is brewing...
/ ._ (
( ' -._ )
\ '. > /
'._'>-'
βββββββββββββββββββββββββββββββββββββββ
β Status: 404 Not Found β
β Server: http://localhost:4180 β
β Press Ctrl+C to stop β
βββββββββββββββββββββββββββββββββββββββ
[14:30:01] GET /api/users β 404 Not Found
[14:30:03] POST /login β 404 Not FoundResponse format
Every request gets a JSON response:
{
"status": 404,
"message": "Not Found",
"rfc": "RFC 7231"
}Plus these headers:
X-Powered-By: 418X-Status-Name: Not FoundAccess-Control-Allow-Origin: *(CORS-friendly)
List all status codes
npx 418 -l 1xx Informational
π 100 Continue Keep going, you're doing great
π 101 Switching Protocols Upgrading to something better
2xx Success
β
200 OK Everything is awesome
πΆ 201 Created Something new was born
4xx Client Error
π» 404 Not Found It's not here. Never was. Maybe
π« 418 I'm a Teapot Short and stout. Tip me over!
...Zero Dependencies
Built with nothing but Node.js built-in http module. No chalk, no express, no commander. Just tea.
Status Codes
All standard HTTP status codes (1xxβ5xx) are supported, including the greats:
| Code | Name | The Vibe | |------|------|----------| | 200 | OK | Everything is awesome | | 301 | Moved Permanently | We've moved. Update your bookmarks | | 404 | Not Found | It's not here. Never was. Maybe | | 418 | I'm a Teapot | Short and stout. Tip me over! | | 429 | Too Many Requests | Slow down! Rate limited | | 451 | Unavailable For Legal Reasons | Censored. Fahrenheit 451 style | | 500 | Internal Server Error | Something broke on our end | | 503 | Service Unavailable | We're down, try again later |
FAQ
Why "418"?
Because RFC 2324 defined the Hyper Text Coffee Pot Control Protocol, which includes the legendary 418 I'm a Teapot status code. It's the internet's best easter egg, and now it's the internet's simplest mock server.
Can I use any status code? Yes! Any code from 100 to 599. If it's a standard code, we'll show you its name and RFC. If it's non-standard, it still works.
Is this production-ready? This is a development tool. Please don't serve your production traffic through a teapot.
License
MIT Β© Zhang Xilin
