-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added typings and adjusted some return vars
- Loading branch information
1 parent
b90925a
commit 022bf01
Showing
4 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
export type WorkerRuntime<T> = { | ||
name: 'cloudflare'; | ||
env: T; | ||
waitUntil(promise: Promise<any>): void; | ||
passThroughOnException(): void; | ||
}; | ||
|
||
export function getRuntime(request: Request): any { | ||
return Reflect.get( | ||
request, | ||
Symbol.for('runtime') | ||
); | ||
} | ||
export type PagesRuntime<T, U> = { | ||
name: 'cloudflare'; | ||
env: T; | ||
functionPath: string; | ||
params: Record<string, string>; | ||
data: U; | ||
waitUntil(promise: Promise<any>): void; | ||
next(request: Request): void; | ||
}; | ||
|
||
export function getRuntime<T, U>(request: Request): WorkerRuntime<T> | PagesRuntime<T, U> { | ||
return Reflect.get(request, Symbol.for('runtime')); | ||
} |
This file contains 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
This file contains 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