@amaurym/now-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Actions Status npm (scoped) dependencies Status Buy me a tree




now-middleware

Chain Express middlewares with Vercel Serverless Functions.




Installation

yarn add @amaurym/now-middleware

Usage

The package exposes one chain function.

import { chain } from '@amaurym/now-middleware';
import { NowRequest, NowResponse } from '@vercel/node';

// Import a couple of Express middlewares
import cors from 'cors'; // Enable cross-origin resource sharing (CORS) with various options
import morgan from 'morgan'; // HTTP request logger

async function handler(_req: NowRequest, res: NowResponse): Promise<void> {
  // This is your normal ZEIT Now function.
  res.send('Everything OK.');
}

// Chain some middlewares before calling the ZEIT Now serverless function
export default chain(cors(), morgan('common'))(handler);

Learn More

Readme

Keywords

none

Package Sidebar

Install

npm i @amaurym/now-middleware

Weekly Downloads

0

Version

0.2.2

License

GPL-3.0

Unpacked Size

46.1 kB

Total Files

10

Last publish

Collaborators

  • amaurym