Skip to content

Commit 604e4cf

Browse files
committed
feat: support env and executionContext for cloudflare
1 parent 7a373ab commit 604e4cf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/pico.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ class Pico extends defineDynamicClass() {
4646

4747
notFound = () => new Response('Not Found', { status: 404 })
4848

49-
fetch = (request: Request) => {
49+
fetch = (request: Request, env?: object, executionContext?: ExecutionContext) => {
5050
const match = this.match(request.method, request.url)
5151
if (match === undefined) return this.notFound()
52-
const response = match.handler({ request, ...match.result })
52+
const response = match.handler({ request, ...match.result, env, executionContext })
5353
if (response instanceof Response) return response
5454
if (typeof response === 'string') {
5555
return new Response(response, {

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export type Handler = (context: Context) => Response | string | object
22
export type Context = {
33
request: Request
4+
env: object
5+
executionContext: ExecutionContext
46
} & URLPatternURLPatternResult

0 commit comments

Comments
 (0)