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
npm install @zaselalk/expressjs-catch-asyncbash
npm i @zaselalk/expressjs-catch-async
`
Usage
To use this package, simply wrap your async route handlers with the catchAsync function:
`javascript
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");
});
``