feat: Moves database dependency directory.
This commit is contained in:
@@ -25,9 +25,9 @@ struct EmployeeApiController: RouteCollection {
|
||||
|
||||
@Sendable
|
||||
func create(req: Request) async throws -> Employee.DTO {
|
||||
try Employee.Create.validate(content: req)
|
||||
let create = try req.content.decode(Employee.Create.self)
|
||||
return try await employees.create(create)
|
||||
try await employees.create(
|
||||
req.ensureValidContent(Employee.Create.self)
|
||||
)
|
||||
}
|
||||
|
||||
@Sendable
|
||||
@@ -42,11 +42,10 @@ struct EmployeeApiController: RouteCollection {
|
||||
|
||||
@Sendable
|
||||
func update(req: Request) async throws -> Employee.DTO {
|
||||
try Employee.Update.validate(content: req)
|
||||
guard let employeeID = req.parameters.get("employeeID", as: Employee.IDValue.self) else {
|
||||
throw Abort(.badRequest, reason: "Employee id value not provided")
|
||||
}
|
||||
let updates = try req.content.decode(Employee.Update.self)
|
||||
let updates = try req.ensureValidContent(Employee.Update.self)
|
||||
return try await employees.update(employeeID, updates)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,8 @@ struct PurchaseOrderApiController: RouteCollection {
|
||||
|
||||
@Sendable
|
||||
func create(req: Request) async throws -> PurchaseOrder.DTO {
|
||||
try PurchaseOrder.Create.validate(content: req)
|
||||
let model = try req.content.decode(PurchaseOrder.Create.self)
|
||||
return try await purchaseOrders.create(
|
||||
model,
|
||||
try await purchaseOrders.create(
|
||||
req.ensureValidContent(PurchaseOrder.Create.self),
|
||||
req.auth.require(User.self).requireID()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -33,9 +33,7 @@ struct UserApiController: RouteCollection {
|
||||
throw Abort(.unauthorized)
|
||||
}
|
||||
}
|
||||
try User.Create.validate(content: req)
|
||||
let model = try req.content.decode(User.Create.self)
|
||||
return try await users.create(model)
|
||||
return try await users.create(req.ensureValidContent(User.Create.self))
|
||||
}
|
||||
|
||||
@Sendable
|
||||
|
||||
@@ -24,9 +24,7 @@ struct VendorApiController: RouteCollection {
|
||||
|
||||
@Sendable
|
||||
func create(req: Request) async throws -> Vendor.DTO {
|
||||
try Vendor.Create.validate(content: req)
|
||||
let model = try req.content.decode(Vendor.Create.self)
|
||||
return try await vendors.create(model)
|
||||
try await vendors.create(req.ensureValidContent(Vendor.Create.self))
|
||||
}
|
||||
|
||||
@Sendable
|
||||
|
||||
@@ -39,9 +39,10 @@ struct VendorBranchApiController: RouteCollection {
|
||||
guard let id = req.parameters.get("vendorID", as: Vendor.IDValue.self) else {
|
||||
throw Abort(.badRequest, reason: "Vendor id not provided.")
|
||||
}
|
||||
try VendorBranch.Create.validate(content: req)
|
||||
let model = try req.content.decode(VendorBranch.Create.self)
|
||||
return try await vendorBranches.create(model, id)
|
||||
return try await vendorBranches.create(
|
||||
req.ensureValidContent(VendorBranch.Create.self),
|
||||
id
|
||||
)
|
||||
}
|
||||
|
||||
@Sendable
|
||||
|
||||
Reference in New Issue
Block a user