You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
792 B

3 years ago
3 years ago
3 years ago
  1. package wow.doge.http4sdemo
  2. import cats.effect.ExitCode
  3. import cats.effect.Resource
  4. import monix.bio.BIOApp
  5. import monix.bio.Task
  6. import monix.bio.UIO
  7. import slick.jdbc.JdbcProfile
  8. object Main extends BIOApp {
  9. val profile: JdbcProfile = slick.jdbc.PostgresProfile
  10. def app = for {
  11. db <- SlickResource("myapp.database")
  12. _ <- Resource.liftF(for {
  13. config <- JdbcDatabaseConfig.loadFromGlobal("myapp.database")
  14. _ <- DBMigrations.migrate(config)
  15. } yield ())
  16. _ <- Resource.liftF(
  17. Task.deferAction(implicit s =>
  18. Http4sdemoServer.stream(db, profile).compile.drain
  19. )
  20. )
  21. } yield ()
  22. def run(args: List[String]) = {
  23. app
  24. .use(_ => Task.never)
  25. .onErrorHandleWith(ex => UIO(ex.printStackTrace()))
  26. .as(ExitCode.Success)
  27. }
  28. }