import { BunContext, BunHttpServer, BunRuntime } from "@effect/platform-bun"
import { Effect, Layer } from "effect"
import { ServerConfig } from "./config"
import { Server } from "./server"


Layer.launch(Server).pipe(
    Effect.provide(Layer.empty.pipe(
        Layer.provideMerge(ServerConfig.httpPort.pipe(
            Effect.map(port => BunHttpServer.layer({ port })),
            Layer.unwrapEffect,
        )),
        Layer.provideMerge(BunContext.layer),
    )),

    BunRuntime.runMain,
)
