Express work

This commit is contained in:
Julien Valverdé
2024-07-11 03:49:14 +02:00
parent a04cd49d03
commit b8210ddd66
5 changed files with 31 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
import { applyWSSHandler } from "@trpc/server/adapters/ws"
import { Effect, Layer } from "effect"
import ws from "ws"
import { Effect, Layer, Runtime } from "effect"
import { WebSocketServer } from "ws"
import { websocketPort } from "../config"
import { TRPCContextCreator } from "../trpc/TRPCContextCreator"
import { RPCRouter } from "./RPCRouter"
@@ -9,7 +9,11 @@ import { RPCRouter } from "./RPCRouter"
export module RPCWebSocketServer {
export const Live = Layer.scopedDiscard(Effect.acquireRelease(
Effect.gen(function*() {
const wss = new ws.Server({ port: yield* websocketPort })
const runSync = yield* Effect.runtime().pipe(
Effect.map(Runtime.runSync)
)
const wss = new WebSocketServer({ port: yield* websocketPort })
const handler = applyWSSHandler({
wss,