diff --git a/src/main/scala/server/Server.scala b/src/main/scala/server/Server.scala index ad4ac18..cd1b0b3 100644 --- a/src/main/scala/server/Server.scala +++ b/src/main/scala/server/Server.scala @@ -1,13 +1,13 @@ package server import cats.effect._ -import cats.implicits.toTraverseOps +import cats.implicits.{catsSyntaxApplicativeError, toTraverseOps} import com.comcast.ip4s.IpLiteralSyntax import data.DataService import db.PostgresService import fetch.FetchService import parse.Aggregate -import server.ValidateRoutes.{AggFieldList, AggKey, CityList, DateTimeRange, Granularity, ValidateDate, ValidateDateTime, ValidateMonths, ValidateInt, ValidateZonedDateTime} +import server.ValidateRoutes.{AggFieldList, AggKey, CityList, DateTimeRange, Granularity, ValidateDate, ValidateDateTime, ValidateInt, ValidateMonths, ValidateZonedDateTime} import io.circe.{Json, Printer} import org.http4s._ import org.http4s.dsl.io._ @@ -19,15 +19,16 @@ import org.http4s.server.staticcontent.FileService import org.http4s.ember.server.EmberServerBuilder import io.circe.generic.auto._ import io.circe.syntax._ +import org.http4s.circe.CirceEntityCodec.circeEntityEncoder import parse.Aggregate.AggregateValueImplicits.aggregateValueEncoder import parse.Aggregate.userQueryEncoder import parse.Aggregate.{AggregateKey, UserQuery} import org.http4s.circe.jsonEncoder import org.typelevel.log4cats.Logger import org.typelevel.log4cats.slf4j.Slf4jLogger -import fs2.io.file.Path import scala.concurrent.duration.DurationInt +import scala.reflect.io.File object Server { @@ -136,8 +137,14 @@ class Server(postgresService: PostgresService, dataService: DataService, fetch: private val apiRoutesCors = CORS(apiRoutes, corsConfig) private val httpApp = Router( + "/api" -> apiRoutesCors, "/" -> staticcontent.fileService[IO](FileService.Config("./web/dist")), - "/api" -> apiRoutesCors + // TODO rewrite in more generic way + "/station" -> staticcontent.fileService[IO](FileService.Config("./web/dist")), + "/cities" -> staticcontent.fileService[IO](FileService.Config("./web/dist")), + "/latvia" -> staticcontent.fileService[IO](FileService.Config("./web/dist")), + "/database" -> staticcontent.fileService[IO](FileService.Config("./web/dist")), + "/harmonie" -> staticcontent.fileService[IO](FileService.Config("./web/dist")), ).orNotFound def run: IO[ExitCode] =