planning-poker-gwargh/backend/src/main/scala/industries/sunshine/planningpoker/BackendApp.scala

32 lines
814 B
Scala

package industries.sunshine.planningpoker
import cats.effect._
import cats.syntax.all._
import com.comcast.ip4s._
import org.http4s.ember.server._
import fs2._
object BackendApp extends IOApp {
override def run(args: List[String]): IO[ExitCode] = {
val host = host"0.0.0.0"
val port = port"8080"
val wiring = for {
roomService <- Resource.eval(RoomService.make[IO])
auth <- Resource.eval(Auth.make[IO]())
httpService = MyHttpService.create(auth, roomService)
server <- EmberServerBuilder
.default[IO]
.withHost(host)
.withPort(port)
.withHttpWebSocketApp(httpService(_))
.build
} yield server
wiring.use(server =>
IO.delay(println(s"Server Has Started at ${server.address}")) >> IO.never.as(ExitCode.Success))
}
}