Package Exports
- @depot/connectrpc-workers
- @depot/connectrpc-workers/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@depot/connectrpc-workers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@depot/connectrpc-workers
A Connect RPC adapter for Cloudflare Workers.
Installation
You can install the module with your favorite package manager:
pnpm add @depot/connectrpc-workersThis package depends on the peer dependencies @connectrpc/connect and @cloudflare/workers-types.
Usage
You can construct a function to register handlers for your Connect services, then construct a Cloudflare Workers fetch event handler from those routes:
import type {ConnectRouter} from '@connectrpc/connect'
import {connectWorkersAdapter} from '@depot/connectrpc-workers'
function routes(router: ConnectRouter) {
// implement rpc Say(SayRequest) returns (SayResponse)
router.rpc(ElizaService, ElizaService.methods.say, async (req) => ({
sentence: `you said: ${req.sentence}`,
}))
}
const handler = connectWorkersAdapter({routes})
export default {
fetch(request, env, context) {
return handler(request, env, context)
},
} satisfies ExportedHandlerLicense
MIT License, see LICENSE.