Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Default Worker Object for new modules format #76

Closed
GregBrimble opened this issue Feb 9, 2021 · 0 comments · Fixed by #112
Closed

Default Worker Object for new modules format #76

GregBrimble opened this issue Feb 9, 2021 · 0 comments · Fixed by #112

Comments

@GregBrimble
Copy link
Member

Maybe something like this:

declare interface CFWorker<Environment = Record<string, unknown>> {
  fetch(request: Request, env: Environment): Promise<Response>
}

Which would let a user:

declare type Environment = {
  MYKV: KVNamespace
}

export default {
  async fetch(request, env): Promise<Response> {
    await env.MYKV.put('key', 'value')
    return new Response('Hello, world!')
  },
} as CFWorker<Environment>
@mrbbot mrbbot linked a pull request Sep 24, 2021 that will close this issue
threepointone added a commit that referenced this issue Sep 30, 2021
Auto-Generated Types

Types are now automatically generated with releases by parsing the runtime's source code, and merging in overrides/docs defined in this repository (for generics, overloads, comments, etc).

webworker no longer needs to (and shouldn't) be included in tsconfig lib.

The final merged AST that's used to render the TypeScript types, workers.json, is also included in the repository. This could be used to generate bindings for other languages that compile to WebAssembly. Rust output is coming soon.

Closes: #55, #75, #76, #81, #84, #96, #97, #100, #101, #102, #105, #106, #107, #108
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant