🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@simpleview/express-async-handler

Package Overview
Dependencies
Maintainers
12
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simpleview/express-async-handler

TypeScript compliant express route handler

latest
npmnpm
Version
1.0.2
Version published
Maintainers
12
Created
Source

@simpleview/express-async-handler

Wrap an express handler to properly handle async errors. Same as npm express-async-handler but with better typing.

Installation

npm install @simpleview/express-async-handler

Use

Basic Example

import express from "express";
import { asyncWrap } from "@simpleview/express-async-handler";

const app = express();
app.get("/", asyncWrap(async function(req, res, next) {
    // any errors thrown will be passed on to next() automatically
});

With custom typing

In order to get rich typing you'll want to setup some helper types. There are two primary needs for custom typing.

  • Customization of the Application locals (req.app.locals, res.app.locals).
  • Customization of the Request (req.query, req.body, req.session).

There is a full example in examples/custom_typing.

FAQs

Package last updated on 05 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts