git.iko.soy/rowtype-yoga/purescript-yoga-bun-yoga
on main help sign in
Prepare for publish v0.2.0
commit3a8638f5baadda71a3993f72fdccbe37b4b761c5 authorMark <mark.eibes@gmail.com> dateMon 16 Feb 2026, 23:45 (7 months ago) parent95a1ca3
3 files changed+21−5
spago.yaml+1−1 src/Yoga/Bun/HTTP.js+7−1 src/Yoga/Bun/HTTP.purs+13−3
spago.yaml+1−1
@@ -3,7 +3,7 @@ workspace: {}
33package:
44 name: yoga-bun-yoga
55 publish:
6− version: 0.1.0
6+ version: 0.2.0
77 license: MIT
88 location:
99 githubOwner: rowtype-yoga
src/Yoga/Bun/HTTP.js+7−1
@@ -1,4 +1,10 @@
1−export const serveImpl = (options) => Bun.serve(options);
1+export const serveImpl = (options) => {
2+ const server = Bun.serve(options);
3+ return {
4+ stop: (close) => server.stop(close),
5+ upgrade: (req) => () => server.upgrade(req)
6+ };
7+};
28
39// String/text Response
410export const stringResponseImpl = (body, stuff) => new Response(body, stuff);
src/Yoga/Bun/HTTP.purs+13−3
@@ -13,15 +13,24 @@ import Promise.Aff (toAffE, fromAff) as Promise
1313import Web.Fetch.Request (Request)
1414import Web.Fetch.Response (Response)
1515
16−type BunServerImpl = { stop :: EffectFn1 Boolean (Promise Unit) }
16+type BunServerImpl = { stop :: EffectFn1 Boolean (Promise Unit), upgrade :: EffectFn1 Request Boolean }
1717
1818data CloseActiveConnections = WaitForOpenConnections | ForceTerminateAllOpenConnections
1919
20−type BunServer = { stop :: CloseActiveConnections -> Aff Unit }
20+type BunServer = { stop :: CloseActiveConnections -> Aff Unit, upgrade :: Request -> Effect Boolean }
2121
2222foreign import serveImpl :: forall options. EffectFn1 options BunServerImpl
2323
24−type BunServeOptionsImpl = (fetch :: EffectFn1 Request (Promise Response), port :: Int, host :: String)
24+type BunServeOptionsImpl =
25+ ( fetch :: EffectFn1 Request (Promise Response)
26+ , port :: Int
27+ , host :: String
28+ , websocket ::
29+ { open :: EffectFn1 Foreign Unit
30+ , message :: EffectFn2 Foreign Foreign Unit
31+ , close :: EffectFn2 Foreign Foreign Unit
32+ }
33+ )
2534
2635serve :: forall opts opts_. Union opts opts_ BunServeOptionsImpl => { fetch :: EffectFn1 Request (Promise Response) | opts } -> Effect BunServer
2736serve opts = do
@@ -30,6 +39,7 @@ serve opts = do
3039 { stop: \closeActiveConnections -> case closeActiveConnections of
3140 WaitForOpenConnections -> runEffectFn1 serverImpl.stop true # Promise.toAffE
3241 ForceTerminateAllOpenConnections -> runEffectFn1 serverImpl.stop false # Promise.toAffE
42+ , upgrade: runEffectFn1 serverImpl.upgrade
3343 }
3444
3545mkFetch :: (Request -> Aff Response) -> EffectFn1 Request (Promise Response)