From 7735f2f03c90aaea0f4878b97bfe9d1fdb82c42d Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 23 Oct 2024 09:36:24 +0900 Subject: [PATCH] fix(vercel): remove `requestContext` (#3549) --- src/adapter/vercel/handler.test.ts | 29 ++++++++++------------------- src/adapter/vercel/handler.ts | 5 ++--- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/adapter/vercel/handler.test.ts b/src/adapter/vercel/handler.test.ts index ef74d1d6..669c3bd9 100644 --- a/src/adapter/vercel/handler.test.ts +++ b/src/adapter/vercel/handler.test.ts @@ -1,28 +1,23 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { Hono } from '../../hono' import { handle } from './handler' describe('Adapter for Next.js', () => { - it('Should return 200 response with a `waitUntil` value', async () => { + it('Should return 200 response', async () => { const app = new Hono() - app.get('/api/foo', async (c) => { + app.get('/api/author/:name', async (c) => { + const name = c.req.param('name') return c.json({ - path: '/api/foo', - /** - * Checking if the `waitUntil` value is passed. - */ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - waitUntil: c.executionCtx.waitUntil() as any, + path: '/api/author/:name', + name, }) }) const handler = handle(app) - const req = new Request('http://localhost/api/foo') - const res = await handler(req, { waitUntil: () => 'waitUntil' } as any) + const req = new Request('http://localhost/api/author/hono') + const res = await handler(req) expect(res.status).toBe(200) expect(await res.json()).toEqual({ - path: '/api/foo', - waitUntil: 'waitUntil', + path: '/api/author/:name', + name: 'hono', }) }) @@ -38,10 +33,6 @@ describe('Adapter for Next.js', () => { const handler = handle(app) const req = new Request('http://localhost/api/error') - expect(() => - handler(req, { - waitUntil: () => {}, - } as any) - ).toThrowError('Custom Error') + expect(() => handler(req)).toThrowError('Custom Error') }) }) diff --git a/src/adapter/vercel/handler.ts b/src/adapter/vercel/handler.ts index 26f70e03..df43dff5 100644 --- a/src/adapter/vercel/handler.ts +++ b/src/adapter/vercel/handler.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import type { Hono } from '../../hono' -import type { FetchEventLike } from '../../types' export const handle = (app: Hono) => - (req: Request, requestContext: FetchEventLike): Response | Promise => { - return app.fetch(req, {}, requestContext as any) + (req: Request): Response | Promise => { + return app.fetch(req) }