Effect CommunityEC
Effect Community8mo ago
5 replies
imagio

Adding Additional Endpoints to an RPC Server with HttpRouter

I'm probably missing something obvious but how do I add additional HttpRouter endpoints to an RPC server?

const SomeEndpoint = HttpRouter.post('/someEndpoint', ....)

// Choose the protocol and serialization format
const HttpProtocol = RpcServer.layerProtocolHttp({
  path: "/rpc"
}).pipe(Layer.provide(RpcSerialization.layerNdjson))

// Create the main server layer
const Main = HttpRouter.Default.serve().pipe(
  // how can I add SomeEndpoint to the server?
  Layer.provide(RpcLayer),
  Layer.provide(HttpProtocol),
  Layer.provide(BunHttpServer.layer({ port: 3000 }))
)
Was this page helpful?