2025-02-27 18:45:46 +01:00
|
|
|
package lu.foyer
|
|
|
|
|
|
2025-02-28 05:40:32 +01:00
|
|
|
import lu.foyer.clients.*
|
2025-02-27 18:45:46 +01:00
|
|
|
import zio.*
|
|
|
|
|
import zio.Console.*
|
|
|
|
|
import zio.http.*
|
|
|
|
|
import zio.http.codec.*
|
2025-02-28 05:40:32 +01:00
|
|
|
import zio.http.codec.PathCodec.path
|
|
|
|
|
import zio.http.endpoint.*
|
2025-02-27 18:45:46 +01:00
|
|
|
import zio.http.endpoint.openapi.OpenAPIGen
|
|
|
|
|
import zio.http.endpoint.openapi.SwaggerUI
|
2025-02-28 05:40:32 +01:00
|
|
|
import zio.schema.*
|
2025-02-27 18:45:46 +01:00
|
|
|
|
2025-02-28 05:40:32 +01:00
|
|
|
import java.net.URI
|
|
|
|
|
import java.time.LocalDate
|
|
|
|
|
import java.util.UUID
|
2025-02-27 18:45:46 +01:00
|
|
|
|
2025-03-03 00:24:13 +01:00
|
|
|
object HttpServer:
|
|
|
|
|
def routes =
|
|
|
|
|
for
|
|
|
|
|
client <- ZIO.service[ClientController]
|
|
|
|
|
openAPI = OpenAPIGen.fromEndpoints(client.endpoints)
|
|
|
|
|
yield client.routes @@ Middleware.debug ++ SwaggerUI.routes("docs" / "openapi", openAPI)
|
|
|
|
|
|
2025-02-27 18:45:46 +01:00
|
|
|
object App extends ZIOAppDefault:
|
2025-03-03 00:24:13 +01:00
|
|
|
val app =
|
|
|
|
|
for
|
|
|
|
|
routes <- HttpServer.routes
|
|
|
|
|
server <- Server.serve(routes).provide(Server.default)
|
|
|
|
|
yield server
|
2025-02-27 18:45:46 +01:00
|
|
|
|
2025-03-03 00:24:13 +01:00
|
|
|
override def run = app.provide(
|
|
|
|
|
CommandEngine.layer[ClientCommand, ClientEvent, ClientState],
|
|
|
|
|
ClientHandlers.layer,
|
|
|
|
|
ClientReducer.layer,
|
|
|
|
|
ClientEventRepositoryInMemory.layer,
|
|
|
|
|
ClientStateRepositoryInMemory.layer,
|
|
|
|
|
ClientController.layer
|
|
|
|
|
)
|