http-error-kit
Seamless Express 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 Express?@wthek/express-middleware
has got you covered!
http-error-kit
Extension – The recommended middleware for Express.js apps.npm install @wthek/express-middleware
Add Middleware Just Before Starting the Server
To catch all errors correctly, place KitExpressMiddleware()
after all routes but before starting your Express server.
import express from "express";
import { KitHttpError, BadRequestError } from "http-error-kit";
import { KitExpressMiddleware } from "@wthek/express-middleware";
const app = express();
// Routes
app.get("/", (req, res) => {
throw new BadRequestError("Invalid request!");
});
// Error Handling Middleware (must be after routes)
app.use(KitExpressMiddleware());
// Start Server
app.listen(3000, () => {
console.log("Server running on port 3000");
});
http-error-kit
Errors@wthek/express-middleware
?http-error-kit
– Fully compatible with existing http-error-kit
error structures.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
The original author of the project is Himanshu Bansal
This is all voluntary work, so if you want to support my efforts you can
You can also use the following:
@wthek/express-middleware
project is open-sourced software licensed under the MIT license by Himanshu Bansal.