Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies to latest #192

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.2
sbt.version=1.9.8
14 changes: 7 additions & 7 deletions src/main/g8/build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
val zioVersion = "2.0.13"
val zioJsonVersion = "0.5.0"
val zioConfigVersion = "3.0.7"
val zioLoggingVersion = "2.1.11"
val zioVersion = "2.0.21"
val zioJsonVersion = "0.6.2"
val zioConfigVersion = "4.0.1"
val zioLoggingVersion = "2.1.16"
val logbackClassicVersion = "1.4.7"
val postgresqlVersion = "42.6.0"
val testContainersVersion = "0.40.15"
val zioMockVersion = "1.0.0-RC11"
val zioHttpVersion = "3.0.0-RC1"
val quillVersion = "4.6.0.1"
val zioMockVersion = "1.0.0-RC12"
val zioHttpVersion = "3.0.0-RC4"
val quillVersion = "4.8.0"

lazy val root = (project in file("."))
.settings(
Expand Down
2 changes: 1 addition & 1 deletion src/main/g8/default.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=zio-scala3-quickstart
description=This is a seed project that creates Scala 3 based ZIO application.
scala_version=3.2.2
scala_version=3.3.1
organization=com.example
package=$organization$
2 changes: 1 addition & 1 deletion src/main/g8/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.2
sbt.version=1.9.8
2 changes: 1 addition & 1 deletion src/main/g8/src/main/scala/$package$/api/Extensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private[api] object Extensions:
def toResponseZIO(implicit ev: JsonEncoder[T]): UIO[Response] = toResponseZIO(Status.Ok)

def toResponseZIO(status: Status)(implicit ev: JsonEncoder[T]): UIO[Response] = ZIO.succeed {
Response.json(data.toJson).withStatus(status)
Response.json(data.toJson).status(status)
}

def toEmptyResponseZIO: UIO[Response] = toEmptyResponseZIO(Status.NoContent)
Expand Down
13 changes: 6 additions & 7 deletions src/main/g8/src/main/scala/$package$/api/HealthCheckRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import zio.http._

object HealthCheckRoutes:

val app: HttpApp[HealthCheckService, Nothing] = Http.collectZIO {

case Method.HEAD -> !! / "healthcheck" =>
val app: HttpApp[HealthCheckService] = Routes(
Method.HEAD / "healthcheck" -> handler { (_: Request) =>
ZIO.succeed {
Response.status(Status.NoContent)
}

case Method.GET -> !! / "healthcheck" =>
},
Method.GET / "healthcheck" -> handler { (_: Request) =>
HealthCheckService.check.map { dbStatus =>
if (dbStatus.status) Response.ok
else Response.status(Status.InternalServerError)
}

}
},
).toHttpApp
23 changes: 14 additions & 9 deletions src/main/g8/src/main/scala/$package$/api/HttpRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import zio.json._

object HttpRoutes extends JsonSupport:

val app: HttpApp[ItemRepository, Nothing] = Http.collectZIO {
case Method.GET -> !! / "items" =>
val app: HttpApp[ItemRepository] = Routes(
Method.GET / "items" -> handler { (_: Request) =>
val effect: ZIO[ItemRepository, DomainError, List[Item]] =
ItemService.getAllItems()

effect.foldZIO(Utils.handleError, _.toResponseZIO)

case Method.GET -> !! / "items" / itemId =>
},
Method.GET / "items" / string("itemId") -> handler { (itemId: String, _: Request) =>
val effect: ZIO[ItemRepository, DomainError, Item] =
for {
id <- Utils.extractLong(itemId)
Expand All @@ -30,7 +31,8 @@ object HttpRoutes extends JsonSupport:

effect.foldZIO(Utils.handleError, _.toResponseZIO)

case Method.DELETE -> !! / "items" / itemId =>
},
Method.DELETE / "items" / string("itemId") -> handler { (itemId: String, _: Request) =>
val effect: ZIO[ItemRepository, DomainError, Unit] =
for {
id <- Utils.extractLong(itemId)
Expand All @@ -41,7 +43,8 @@ object HttpRoutes extends JsonSupport:

effect.foldZIO(Utils.handleError, _.toEmptyResponseZIO)

case req @ Method.POST -> !! / "items" =>
},
Method.POST / "items" -> handler { (req: Request) =>
val effect: ZIO[ItemRepository, DomainError, Item] =
for {
createItem <- req.jsonBodyAs[CreateItemRequest]
Expand All @@ -50,7 +53,8 @@ object HttpRoutes extends JsonSupport:

effect.foldZIO(Utils.handleError, _.toResponseZIO(Status.Created))

case req @ Method.PUT -> !! / "items" / itemId =>
},
Method.PUT / "items" / string("itemId") -> handler { (itemId: String, req: Request) =>
val effect: ZIO[ItemRepository, DomainError, Item] =
for {
id <- Utils.extractLong(itemId)
Expand All @@ -63,7 +67,8 @@ object HttpRoutes extends JsonSupport:

effect.foldZIO(Utils.handleError, _.toResponseZIO)

case req @ Method.PATCH -> !! / "items" / itemId =>
},
Method.PATCH / "items" / string("itemId") -> handler { (itemId: String, req: Request) =>
val effect: ZIO[ItemRepository, DomainError, Item] =
for {
id <- Utils.extractLong(itemId)
Expand All @@ -79,5 +84,5 @@ object HttpRoutes extends JsonSupport:
} yield item

effect.foldZIO(Utils.handleError, _.toResponseZIO)

}
},
).toHttpApp
18 changes: 9 additions & 9 deletions src/main/g8/src/main/scala/$package$/config/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ package $package$.config
import com.typesafe.config.ConfigFactory
import zio._
import zio.config._
import zio.config.ConfigDescriptor._
import zio.config.typesafe.TypesafeConfigSource
import zio.config.typesafe._
import zio.Config._
import zio.config.typesafe.TypesafeConfigProvider

object Configuration:

final case class ApiConfig(host: String, port: Int)

object ApiConfig:

private val serverConfigDescription =
nested("api") {
string("host") <*>
int("port")
}.to[ApiConfig]
private val serverConfigDescription: Config[ApiConfig] =
(string("host") zip int("port"))
.nested("api")
.to[ApiConfig]

val layer = ZLayer(
read(
serverConfigDescription.from(
TypesafeConfigSource.fromTypesafeConfig(
ZIO.attempt(ConfigFactory.defaultApplication())
TypesafeConfigProvider.fromTypesafeConfig(
ConfigFactory.defaultApplication()
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object HealthCheckRoutesSpec extends ZIOSpecDefault:
suite("health check")(
test("ok status") {
val actual =
HealthCheckRoutes.app.runZIO(Request.get(URL(!! / "healthcheck")))
HealthCheckRoutes.app.runZIO(Request.get(URL(Path("healthcheck"))))
assertZIO(actual)(equalTo(Response(Status.Ok, Headers.empty, Body.empty)))
}
)
Expand Down