Skip to content

altipla-consulting/express-async-handler

Repository files navigation

express-async-handler

Transform async handlers to use them in Express v4.

Install

npm install @altipla/express-async-handler

Usage

import express from 'express'
import type { Request, Response } from 'express'
import { asyncHandler } from '@altipla/express-async-handler'

async function exampleHandler(req: Request, res: Response) {
  await (...)
  return 'ok'
}

let app = express()
app.use('/example', asyncHandler(exampleHandler))