feat: Adds component pressure loss to database client and api routes.

This commit is contained in:
2025-12-29 17:04:25 -05:00
parent a2514853a6
commit 6eedb7396d
4 changed files with 249 additions and 3 deletions

View File

@@ -10,6 +10,8 @@ extension SiteRoute {
case project(Self.ProjectRoute)
case room(Self.RoomRoute)
case equipment(Self.EquipmentRoute)
case componentLoss(Self.ComponentLossRoute)
public static let rootPath = Path {
"api"
@@ -25,6 +27,14 @@ extension SiteRoute {
rootPath
RoomRoute.router
}
Route(.case(Self.equipment)) {
rootPath
EquipmentRoute.router
}
Route(.case(Self.componentLoss)) {
rootPath
ComponentLossRoute.router
}
}
}
@@ -109,7 +119,7 @@ extension SiteRoute.Api {
case fetch(projectID: Project.ID)
case get(id: EquipmentInfo.ID)
static let rootPath = "rooms"
static let rootPath = "equipment"
public static let router = OneOf {
Route(.case(Self.create)) {
@@ -141,3 +151,44 @@ extension SiteRoute.Api {
}
}
}
extension SiteRoute.Api {
public enum ComponentLossRoute: Sendable, Equatable {
case create(ComponentPressureLoss.Create)
case delete(id: ComponentPressureLoss.ID)
case fetch(projectID: Project.ID)
case get(id: ComponentPressureLoss.ID)
static let rootPath = "componentLoss"
public static let router = OneOf {
Route(.case(Self.create)) {
Path { rootPath }
Method.post
Body(.json(ComponentPressureLoss.Create.self))
}
Route(.case(Self.delete(id:))) {
Path {
rootPath
ComponentPressureLoss.ID.parser()
}
Method.delete
}
Route(.case(Self.fetch(projectID:))) {
Path { rootPath }
Method.get
Query {
Field("projectID") { Project.ID.parser() }
}
}
Route(.case(Self.get(id:))) {
Path {
rootPath
ComponentPressureLoss.ID.parser()
}
Method.get
}
}
}
}