Skip to the content.

Official @wthek Extension – Restify Middleware for http-error-kit

Seamless Restify Error Handling with @wthek

Built for applications powered by http-error-kit, this middleware ensures that all http-error-kit errors are properly formatted and returned with the correct HTTP status codes.

💡 What the HEK?! Need a hassle-free way to manage error responses for http-error-kit errors in Restify? @wthek/restify-middleware has got you covered!

GitHub Workflow Status npm version GitHub license GitHub Issues Codacy Badge Codacy Badge npms.io (final) npm Socket Badge GitHub Pages Github Sponsors Open Collective Buy Me A Coffee Patreon PayPal

Features

Table of Content

Installation

npm install @wthek/restify-middleware

Usage

Add Middleware Just Before Starting the Server

To catch all errors correctly, place KitRestifyMiddleware() after all routes but before starting your Restify server.

import restify from 'restify';
import { KitHttpError, BadRequestError } from "http-error-kit";
import { KitRestifyMiddleware } from "@wthek/restify-middleware";

const server = restify.createServer();

server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());

server.get('/test', (req, res, next) => {
  return next(new KitHttpError('This is a bad request', { statusCode: 400 }));
});

// Error handler
server.on('restifyError', KitRestifyMiddleware());

server.listen(3000, () => {
  console.log('🚀 Server listening on http://localhost:3000');
});

How It Works

Why Use @wthek/restify-middleware?

Explore More WTHek Extensions

The WTHek ecosystem continues to grow with new extensions to simplify error handling across various frameworks and libraries. Stay updated with the latest tools that integrate seamlessly with http-error-kit.

Check out the official list of extensions: Official Extensions List

People

The original author of the project is Himanshu Bansal

Donations

This is all voluntary work, so if you want to support my efforts you can

You can also use the following:

BTC: qzqmpxux3m56qqhz465u8022q9z63w2sysq4u9ltwj

ETH: 0x1D59a291391a3CE17C63D5dC50F258Dc0Ab62889

License

@wthek/restify-middleware project is open-sourced software licensed under the MIT license by Himanshu Bansal.