Implemented phase 5 for the POC prototype in the Website service.

This commit is contained in:
javier committed 2026-09-21 13:32:05 +02:00
1 parent 89a7a7b8e5
commit 31d2d98d49
46 files changed
+4039 -162

No files matched your search

@@ -1,5 +1,6 @@
import Configuration
import Hummingbird
import HummingbirdFluent
import Localization
import Logging
import Persistence
@@ -71,6 +72,7 @@ func application(
logLevel: reader.logLevel,
passkeysOrigin: reader.passkeysOrigin,
probe: Probe(fluent: fluent),
fluent: fluent,
accounts: AccountRepository(fluent: fluent),
trade: TradeRepository(fluent: fluent),
repository: repository,
@@ -186,6 +188,7 @@ private func logger(
/// - logLevel: the level the request-logging middleware logs at.
/// - passkeysOrigin: the origin the `PasskeyController` binds passkeys to.
/// - probe: the probe consulted by the `HealthController` readiness route.
/// - fluent: the service the remaining repositories are built on.
/// - accounts: the repository the `SessionController` finds and creates accounts through.
/// - trade: the repository the `TradeController` reads and writes conversations, offers, and sales through.
/// - repository: the repository the `CatalogueController` reads the shops and listings through.
@@ -204,6 +207,7 @@ private func router(
logLevel: Logger.Level,
passkeysOrigin: String,
probe: Probe,
fluent: Fluent,
accounts: AccountRepository,
trade: TradeRepository,
repository: CatalogueRepository,
@@ -215,7 +219,26 @@ private func router(
context: AppRequestContext.self,
options: .autoGenerateHeadEndpoints
)
let sessions = SessionStore(trade: trade)
let collecting = CollectingRepository(fluent: fluent)
let sessions = SessionStore(
trade: trade,
collecting: collecting
)
let root = RootController<AppRequestContext>(
assetVersion: assetVersion,
siteOrigin: siteOrigin,
analytics: analytics,
listings: listings,
sessions: sessions
)
// A sale takes a copy off the landing page and a new listing puts one on; either renders it again.
let refreshHome: @Sendable () async -> Void = { [home = root.home] in
guard let listings = try? await repository.listings() else {
return
}
await home.refresh(with: .init(from: listings))
}
router.addMiddleware {
LogRequestsMiddleware(logLevel)
@@ -241,13 +264,7 @@ private func router(
}
router.addController {
RootController<AppRequestContext>(
assetVersion: assetVersion,
siteOrigin: siteOrigin,
analytics: analytics,
listings: listings,
sessions: sessions
)
root
CatalogueController<AppRequestContext>(
repository: repository,
sessions: sessions,
@@ -263,6 +280,20 @@ private func router(
assetVersion: assetVersion,
analytics: analytics
)
AccountController<AppRequestContext>(
accounts: accounts,
catalogue: repository,
sessions: sessions,
assetVersion: assetVersion,
analytics: analytics
)
CollectingController<AppRequestContext>(
collecting: collecting,
catalogue: repository,
sessions: sessions,
assetVersion: assetVersion,
analytics: analytics
)
PasskeyController<AppRequestContext>(
origin: passkeysOrigin,
accounts: accounts,
@@ -274,14 +305,16 @@ private func router(
sessions: sessions,
photos: PhotoStore(staticFilesPath: staticFilesPath),
assetVersion: assetVersion,
analytics: analytics
analytics: analytics,
onCatalogueChange: refreshHome
)
TradeController<AppRequestContext>(
trade: trade,
catalogue: repository,
sessions: sessions,
assetVersion: assetVersion,
analytics: analytics
analytics: analytics,
onCatalogueChange: refreshHome
)
HealthController<AppRequestContext>(
probe: probe