generated from kevchuang/scala3-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): Implement get company by id (#13)
- Loading branch information
Showing
7 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...erver/src/main/scala/io/kevchuang/reviewboard/http/endpoints/GetCompanyByIdEndpoint.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.kevchuang.reviewboard.http.endpoints | ||
|
||
import io.kevchuang.reviewboard.domain.company.* | ||
import io.kevchuang.reviewboard.services.company.CompanyService | ||
import io.kevchuang.reviewboard.services.db.DatabaseService | ||
import sttp.model.StatusCode | ||
import sttp.tapir.* | ||
import sttp.tapir.json.zio.* | ||
import sttp.tapir.generic.auto.* | ||
import sttp.tapir.codec.iron.{*, given} | ||
import zio.ZIO | ||
|
||
final case class GetCompanyByIdEndpoint() | ||
extends HttpEndpoint[ | ||
DatabaseService & CompanyService, | ||
CompanyId, | ||
CompanyNotFound, | ||
Company | ||
]: | ||
|
||
override def endpointDescription | ||
: ApiEndpoint[CompanyId, CompanyNotFound, Company] = | ||
endpoint | ||
.tag("companies") | ||
.name("getById") | ||
.description("get company by its id") | ||
.in("companies" / path[CompanyId]("companyId")) | ||
.get | ||
.errorOut(jsonBody[CompanyNotFound]) | ||
.out(jsonBody[Company]) | ||
|
||
override def endpointLogic: CompanyId => ZIO[ | ||
DatabaseService & CompanyService, | ||
CompanyNotFound, | ||
Company | ||
] = CompanyService.getCompanyById | ||
end GetCompanyByIdEndpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters