Created
March 24, 2022 22:30
-
-
Save dbrrt/1cf5bb4fa3a40a26a45490326dae46fa to your computer and use it in GitHub Desktop.
Wrap a serverless event to a vercel request event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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