fix(context): use `FetchEvent` instead of `FetchEventLike` (#1532)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Yusuke Wada · committed by GitHub · parent 82f1033 · Browse files · 5 files·+25 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+25 added−15 removed
- other:+25 added−15 removed
Provenance
- Commit
e326208- Tree
fc47a71- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
82f1033
5 files changed+25 added−15 removed
modified:deno_dist/context.ts+8 added-5 removed
1+/// <reference lib="es2022" />2+/// <reference lib="webworker" />3+// We need these triple slashes to correctly refer to `FetchEvent` in Deno.4+5 import type { HonoRequest } from './request.ts'2-import { FetchEventLike } from './types.ts'6 import type { Env, NotFoundHandler, Input, TypedResponse } from './types.ts'7 import type { CookieOptions } from './utils/cookie.ts'8 import { serialize } from './utils/cookie.ts'9 import type { StatusCode } from './utils/http-status.ts'74 unmodified lines84 }85 86 type ContextOptions<E extends Env> = {87 env: E['Bindings']85- executionCtx?: FetchEventLike | ExecutionContext | undefined88+ executionCtx?: FetchEvent | ExecutionContext | undefined89 notFoundHandler?: NotFoundHandler<E>90 }91 92 const TEXT_PLAIN = 'text/plain; charset=UTF-8'11 unmodified lines104 finalized: boolean = false105 error: Error | undefined = undefined106 107 private _status: StatusCode = 200105- private _exCtx: FetchEventLike | ExecutionContext | undefined // _executionCtx108+ private _exCtx: FetchEvent | ExecutionContext | undefined // _executionCtx109 private _h: Headers | undefined = undefined // _headers110 private _pH: Record<string, string> | undefined = undefined // _preparedHeaders111 private _res: Response | undefined112 private _init = true10 unmodified lines123 }124 }125 }126 124- get event(): FetchEventLike {125- if (this._exCtx instanceof FetchEventLike) {127+ get event(): FetchEvent {128+ if (this._exCtx instanceof FetchEvent) {129 return this._exCtx130 } else {131 throw Error('This context has no FetchEvent')132 }343 unmodified linesmodified:src/context.ts+8 added-5 removed
1+/// <reference lib="es2022" />2+/// <reference lib="webworker" />3+// We need these triple slashes to correctly refer to `FetchEvent` in Deno.4+5 import type { HonoRequest } from './request'2-import { FetchEventLike } from './types'6 import type { Env, NotFoundHandler, Input, TypedResponse } from './types'7 import type { CookieOptions } from './utils/cookie'8 import { serialize } from './utils/cookie'9 import type { StatusCode } from './utils/http-status'74 unmodified lines84 }85 86 type ContextOptions<E extends Env> = {87 env: E['Bindings']85- executionCtx?: FetchEventLike | ExecutionContext | undefined88+ executionCtx?: FetchEvent | ExecutionContext | undefined89 notFoundHandler?: NotFoundHandler<E>90 }91 92 const TEXT_PLAIN = 'text/plain; charset=UTF-8'11 unmodified lines104 finalized: boolean = false105 error: Error | undefined = undefined106 107 private _status: StatusCode = 200105- private _exCtx: FetchEventLike | ExecutionContext | undefined // _executionCtx108+ private _exCtx: FetchEvent | ExecutionContext | undefined // _executionCtx109 private _h: Headers | undefined = undefined // _headers110 private _pH: Record<string, string> | undefined = undefined // _preparedHeaders111 private _res: Response | undefined112 private _init = true10 unmodified lines123 }124 }125 }126 124- get event(): FetchEventLike {125- if (this._exCtx instanceof FetchEventLike) {127+ get event(): FetchEvent {128+ if (this._exCtx instanceof FetchEvent) {129 return this._exCtx130 } else {131 throw Error('This context has no FetchEvent')132 }343 unmodified linesmodified:package.json+1 added-1 removed
396 unmodified lines397 "@hono/node-server": "^1.0.2",398 "@types/crypto-js": "^4.1.1",399 "@types/glob": "^8.0.0",400 "@types/jest": "^29.4.0",401- "@types/node": "^17.0.29",401+ "@types/node": "^20.8.2",402 "@types/node-fetch": "^2.6.2",403 "@types/supertest": "^2.0.12",404 "@typescript-eslint/eslint-plugin": "^5.59.2",405 "@typescript-eslint/parser": "^5.59.2",37 unmodified linesmodified:tsconfig.json+4 added
8 unmodified lines9101112131415161718192011 unmodified lines8 unmodified lines "strict": true, "skipLibCheck": false, "noUnusedLocals": false, "noUnusedParameters": false, "lib": [ "ES2022", "WebWorker" ], "types": [ "jest", "node" ],11 unmodified linesmodified:yarn.lock+4 added-4 removed
1708 unmodified lines1709 version "17.0.13"1710 resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.13.tgz#5ed7ed7c662948335fcad6c412bb42d99ea754e3"1711 integrity sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==1712 1713-"@types/node@^17.0.29":1714- version "17.0.29"1715- resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.29.tgz#7f2e1159231d4a077bb660edab0fde373e375a3d"1716- integrity sha512-tx5jMmMFwx7wBwq/V7OohKDVb/JwJU5qCVkeLMh1//xycAJ/ESuw9aJ9SEtlCZDYi2pBfe4JkisSoAtbOsBNAA==1713+"@types/node@^20.8.2":1714+ version "20.8.2"1715+ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.2.tgz#d76fb80d87d0d8abfe334fc6d292e83e5524efc4"1716+ integrity sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==1717 1718 "@types/normalize-package-data@^2.4.0":1719 version "2.4.1"1720 resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"6355 unmodified lines