Skip to content

Instantly share code, notes, and snippets.

@dbrrt
Created March 24, 2022 22:30
Show Gist options
  • Save dbrrt/1cf5bb4fa3a40a26a45490326dae46fa to your computer and use it in GitHub Desktop.
Save dbrrt/1cf5bb4fa3a40a26a45490326dae46fa to your computer and use it in GitHub Desktop.
Wrap a serverless event to a vercel request event
import type { VercelRequest, VercelResponse } from "@vercel/node";
export const vercelWrapper =
(handler_: Function) => async (req: VercelRequest, res: VercelResponse) => {
const { statusCode, body } = await handler_(req);
res.status(statusCode).json(JSON.parse(body));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment