@zaselalk/expressjs-catch-async
v1.0.2
Published
The catchAsync function is a higher-order function designed to simplify error handling in asynchronous Express.js route handlers and middleware. By wrapping these functions with catchAsync, any errors that occur during their execution are automatically ca
Maintainers
Readme
Express.js Catch Async
This package provides a simple way to handle asynchronous errors in your Express.js applications. It allows you to catch errors in your async route handlers and middleware, ensuring that your application can respond gracefully without crashing.
Installation
To install the package, run:
npm i @zaselalk/expressjs-catch-asyncUsage
To use this package, simply wrap your async route handlers with the catchAsync function:
import express from "express";
import catchAsync from "@zaselalk/expressjs-catch-async";
const app = express();
app.get(
"/some-route",
catchAsync(async (req, res) => {
// Your async code here
})
);
app.listen(3000, () => {
console.log("Server is running on port 3000");
});License
This package is licensed under the MIT License.
