Implement contracts
This commit is contained in:
parent
31014d1a0c
commit
efdc50eb1d
33 changed files with 879 additions and 173 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package lu.foyer
|
||||
|
||||
import lu.foyer.clients.*
|
||||
import lu.foyer.contracts.*
|
||||
import zio.*
|
||||
import zio.Console.*
|
||||
import zio.http.*
|
||||
|
|
@ -10,17 +11,26 @@ import zio.http.endpoint.*
|
|||
import zio.http.endpoint.openapi.OpenAPIGen
|
||||
import zio.http.endpoint.openapi.SwaggerUI
|
||||
import zio.schema.*
|
||||
import zio.http.Middleware.cors
|
||||
import zio.http.Middleware.CorsConfig
|
||||
import zio.http.Header.AccessControlAllowOrigin
|
||||
|
||||
import java.net.URI
|
||||
import java.time.LocalDate
|
||||
import java.util.UUID
|
||||
|
||||
object HttpServer:
|
||||
|
||||
val corsConfig = CorsConfig(_ => Some(AccessControlAllowOrigin.All))
|
||||
|
||||
def routes =
|
||||
for
|
||||
client <- ZIO.service[ClientController]
|
||||
openAPI = OpenAPIGen.fromEndpoints(client.endpoints)
|
||||
yield client.routes @@ Middleware.debug ++ SwaggerUI.routes("docs" / "openapi", openAPI)
|
||||
client <- ZIO.service[ClientController]
|
||||
contract <- ZIO.service[ContractController]
|
||||
openAPI = OpenAPIGen.fromEndpoints(client.endpoints ++ contract.endpoints)
|
||||
yield (client.routes ++ contract.routes)
|
||||
@@ cors(corsConfig) @@ Middleware.debug
|
||||
++ SwaggerUI.routes("docs" / "openapi", openAPI)
|
||||
|
||||
object App extends ZIOAppDefault:
|
||||
val app =
|
||||
|
|
@ -31,9 +41,17 @@ object App extends ZIOAppDefault:
|
|||
|
||||
override def run = app.provide(
|
||||
CommandEngine.layer[ClientCommand, ClientEvent, ClientState],
|
||||
CommandEngine.layer[ContractCommand, ContractEvent, ContractState],
|
||||
ClientHandlers.layer,
|
||||
ContractHandlers.layer,
|
||||
ClientReducer.layer,
|
||||
ContractReducer.layer,
|
||||
ClientEventRepositoryInMemory.layer,
|
||||
ContractEventRepositoryInMemory.layer,
|
||||
ClientStateRepositoryInMemory.layer,
|
||||
ClientController.layer
|
||||
ContractStateRepositoryInMemory.layer,
|
||||
ClientController.layer,
|
||||
ContractController.layer,
|
||||
PremiumServiceImpl.layer,
|
||||
EmployeeServiceImpl.layer
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue