express-teapot

An Teapot middleware for express.

Usage no npm install needed!

<script type="module">
  import expressTeapot from 'https://cdn.skypack.dev/express-teapot';
</script>

README

express-teapot

An express middleware to send HTTP 418 Status codes.

Installation

Using npm:

$ npm i express-teapot

In Node.js:

// Import in app.ts
import teapot from 'express-teapot';

// Use as middleware
app.use(teapot());

// Use as middleware with route
app.use(teapot('/IWantTea'));

// Use as middleware with configuration
app.use(teapot({
    route: '/teapot',
    webpage: `
    <html>
        <head>
            <title>Some Tea for you</title>
        </head>
        <body>
            <h1>HTTP Error 418 - I'm a teapot</h1>
        </body>
    </html>`
}));

API

Teapot

Initializing of the teapot middleware. Leave empty to use the default route and default webpage.

teapot(): express.RequestHandler
teapot(route: string): express.RequestHandler
teapot(config: Configuration): express.RequestHandler

Configuration

Property Default Description
route '/coffee' The route the requesthandler is listening to.
webpage Filecontent of ../static/index.html The webpage that is displayed to the user when visiting the HTTP 418 error page.

Teapot Image

Images by Teapot Vectors by Vecteezy