Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import org.scalajs.linker.interface.ModuleSplitStyle

import scala.sys.process.*

lazy val projectVersion = "2.3.3"
lazy val projectVersion = "2.3.4"
lazy val organizationName = "ru.trett"
lazy val scala3Version = "3.7.4"
lazy val circeVersion = "0.14.15"
lazy val htt4sVersion = "1.0.0-M39"
lazy val htt4sVersion = "1.0.0-M45"
lazy val logs4catVersion = "2.7.1"
lazy val otel4sVersion = "0.14.0"
lazy val doobieVersion = "1.0.0-RC11"
lazy val customScalaOptions = Seq("-Wunused:imports", "-rewrite", "-source:3.4-migration")

lazy val buildClientDist = taskKey[File]("Build client optimized package")
Expand Down Expand Up @@ -117,7 +118,7 @@ lazy val server = project
"org.tpolecat" %% "doobie-hikari",
"org.tpolecat" %% "doobie-postgres",
"org.tpolecat" %% "doobie-postgres-circe"
).map(_ % "1.0.0-RC5"),
).map(_ % doobieVersion),
libraryDependencies += "org.jsoup" % "jsoup" % "1.21.2",
libraryDependencies += "com.github.blemale" %% "scaffeine" % "5.3.0",
libraryDependencies += "org.flywaydb" % "flyway-database-postgresql" % "11.17.2" % "runtime",
Expand Down
2 changes: 1 addition & 1 deletion scripts/local-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- host.docker.internal:host-gateway

server:
image: server:2.3.3
image: server:2.3.4
container_name: rss_server
restart: always
depends_on:
Expand Down
46 changes: 24 additions & 22 deletions server/src/main/scala/ru/trett/rss/server/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,37 +108,39 @@ object Server extends IOApp:
_ <- logger.info(
"Starting server on port: " + appConfig.server.port
)
authFilter <- AuthFilter[IO]
jarRoutes <- resourceServiceBuilder[IO]("/public").toRoutes
appRoutes <-
corsPolicy(
jarRoutes <+>
routes(
sessionManager,
channelService,
userService,
feedService,
appConfig.oauth,
authFilter,
client,
summarizeService,
new LogoutController[IO](
sessionManager
)
)
)
exitCode <- UpdateTask(
channelService,
userService
).background.void
.surround {
for {
authFilter <- AuthFilter[IO]
server <- EmberServerBuilder
.default[IO]
.withHost(ipv4"0.0.0.0")
.withPort(
Port.fromInt(appConfig.server.port).get
)
.withHttpApp(
withErrorLogging(
corsPolicy(
routes(
sessionManager,
channelService,
userService,
feedService,
appConfig.oauth,
authFilter,
client,
summarizeService,
new LogoutController[IO](
sessionManager
)
)
)
).orNotFound
withErrorLogging(appRoutes).orNotFound
)
.build
.use(_ => IO.never)
Expand Down Expand Up @@ -204,19 +206,19 @@ object Server extends IOApp:
logoutController
)
)
private def resourceRoutes: HttpRoutes[IO] =
val indexRoute = HttpRoutes.of[IO] { case request @ GET -> Root =>

private def indexRoute: HttpRoutes[IO] =
HttpRoutes.of[IO] { case request @ GET -> Root =>
StaticFile.fromResource("/public/index.html", Some(request)).getOrElseF(NotFound())
}
indexRoute <+> resourceServiceBuilder[IO]("/public").toRoutes

private def unprotectedRoutes(
sessionManager: SessionManager[IO],
oauthConfig: OAuthConfig,
userService: UserService,
client: Client[IO]
): HttpRoutes[IO] =
LoginController.routes(sessionManager, oauthConfig, userService, client) <+> resourceRoutes
LoginController.routes(sessionManager, oauthConfig, userService, client) <+> indexRoute

private def authedRoutes(
channelService: ChannelService,
Expand Down