Effect CommunityEC
Effect Community7mo ago
3 replies
Riordan

Accessing HttpServerRequest from within an RPC in Effect Typescript library

(answer: no, its protocol independent)
Can I access HttpServerRequest from within an rpc?
I currently have:
const RpcLayer = RpcServer.layer(Rpcs).pipe(Layer.provide(RpcsLive));

// 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(
  Layer.provide(RpcLayer),
  Layer.provideMerge(PrismaLayer),
  Layer.provide(HttpProtocol),
  Layer.provide(
    NodeHttpServer.layer(createServer, {
      port: process.env.SERVER_PORT ? Number(process.env.SERVER_PORT) : 3001,
    }),
  ),
  Layer.provideMerge(NodeObservability),
);

NodeRuntime.runMain(Layer.launch(Main));
Was this page helpful?