Minor Changes
- #2261
fa9663c
Thanks @tim-smart! - move Socket module to platform
Patch Changes
-
#2261
fa9663c
Thanks @tim-smart! - add websocket support to platform http serverYou can use the
Http.request.upgrade*
apis to access theSocket
for the request.Here is an example server that handles websockets on the
/ws
path:import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"; import * as Http from "@effect/platform/HttpServer"; import { Console, Effect, Layer, Schedule, Stream } from "effect"; import { createServer } from "node:http"; const ServerLive = NodeHttpServer.server.layer(() => createServer(), { port: 3000, }); const HttpLive = Http.router.empty.pipe( Http.router.get( "/ws", Effect.gen(function* (_) { yield* _( Stream.fromSchedule(Schedule.spaced(1000)), Stream.map(JSON.stringify), Stream.encodeText, Stream.pipeThroughChannel(Http.request.upgradeChannel()), Stream.decodeText(), Stream.runForEach(Console.log), ); return Http.response.empty(); }), ), Http.server.serve(Http.middleware.logger), Http.server.withLogAddress, Layer.provide(ServerLive), ); NodeRuntime.runMain(Layer.launch(HttpLive));
-
Updated dependencies [
e03811e
,ac41d84
,0f3d99c
,6137533
,f373529
,1bf9f31
,e3ff789
,6137533
,507ba40
,4064ea0
,e466afe
,f373529
,de74eb8
,fa9663c
,fa9663c
]:- effect@2.4.2
- @effect/platform-node-shared@0.2.4
- @effect/platform@0.47.0