github Effect-TS/effect @effect/platform-bun@0.32.11

latest releases: @effect/sql-sqlite-node@0.19.5, @effect/sql-sqlite-react-native@0.21.5, @effect/sql-sqlite-wasm@0.18.5...
7 months ago

Patch Changes

  • #2267 0f3d99c Thanks @tim-smart! - propogate Socket handler errors to .run Effect

  • #2261 fa9663c Thanks @tim-smart! - add websocket support to platform http server

    You can use the Http.request.upgrade* apis to access the Socket 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

Don't miss a new effect release

NewReleases is sending notifications on new releases.