feat: Begins integrating database client into vapor app.
This commit is contained in:
@@ -27,37 +27,3 @@ public extension DatabaseClient {
|
||||
extension DatabaseClient.Employees: TestDependencyKey {
|
||||
public static let testValue = Self()
|
||||
}
|
||||
|
||||
public extension Employee {
|
||||
struct Create: Codable, Sendable {
|
||||
public let firstName: String
|
||||
public let lastName: String
|
||||
public let active: Bool?
|
||||
|
||||
public init(
|
||||
firstName: String,
|
||||
lastName: String,
|
||||
active: Bool? = nil
|
||||
) {
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.active = active
|
||||
}
|
||||
}
|
||||
|
||||
struct Update: Codable, Sendable {
|
||||
public let firstName: String?
|
||||
public let lastName: String?
|
||||
public let active: Bool?
|
||||
|
||||
public init(
|
||||
firstName: String? = nil,
|
||||
lastName: String? = nil,
|
||||
active: Bool? = nil
|
||||
) {
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.active = active
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,3 @@ public extension DatabaseClient {
|
||||
extension DatabaseClient.PurchaseOrders: TestDependencyKey {
|
||||
public static let testValue: DatabaseClient.PurchaseOrders = Self()
|
||||
}
|
||||
|
||||
public extension PurchaseOrder {
|
||||
struct Create: Codable, Sendable {
|
||||
|
||||
public let id: Int?
|
||||
public let workOrder: Int?
|
||||
public let materials: String
|
||||
public let customer: String
|
||||
public let truckStock: Bool?
|
||||
public let createdForID: Employee.ID
|
||||
public let vendorBranchID: VendorBranch.ID
|
||||
|
||||
public init(
|
||||
id: Int? = nil,
|
||||
workOrder: Int? = nil,
|
||||
materials: String,
|
||||
customer: String,
|
||||
truckStock: Bool? = nil,
|
||||
createdForID: Employee.ID,
|
||||
vendorBranchID: VendorBranch.ID
|
||||
) {
|
||||
self.id = id
|
||||
self.workOrder = workOrder
|
||||
self.materials = materials
|
||||
self.customer = customer
|
||||
self.truckStock = truckStock
|
||||
self.createdForID = createdForID
|
||||
self.vendorBranchID = vendorBranchID
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ import Dependencies
|
||||
import DependenciesMacros
|
||||
import Foundation
|
||||
import SharedModels
|
||||
import Vapor
|
||||
|
||||
public extension DatabaseClient {
|
||||
|
||||
@DependencyClient
|
||||
struct Users: Sendable {
|
||||
public var count: @Sendable () async throws -> Int
|
||||
public var create: @Sendable (User.Create) async throws -> User
|
||||
public var delete: @Sendable (User.ID) async throws -> Void
|
||||
public var fetchAll: @Sendable () async throws -> [User]
|
||||
@@ -16,61 +18,12 @@ public extension DatabaseClient {
|
||||
}
|
||||
}
|
||||
|
||||
public extension DatabaseClient.Users {
|
||||
enum AuthRequest {
|
||||
case basic(BasicAuthorization)
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseClient.Users: TestDependencyKey {
|
||||
public static let testValue: DatabaseClient.Users = Self()
|
||||
}
|
||||
|
||||
public extension User {
|
||||
|
||||
struct Create: Codable, Sendable {
|
||||
public let username: String
|
||||
public let email: String
|
||||
public let password: String
|
||||
public let confirmPassword: String
|
||||
|
||||
public init(
|
||||
username: String,
|
||||
email: String,
|
||||
password: String,
|
||||
confirmPassword: String
|
||||
) {
|
||||
self.username = username
|
||||
self.email = email
|
||||
self.password = password
|
||||
self.confirmPassword = confirmPassword
|
||||
}
|
||||
}
|
||||
|
||||
struct Login: Codable, Sendable {
|
||||
public let username: String?
|
||||
public let email: String?
|
||||
public let password: String
|
||||
|
||||
public init(
|
||||
username: String?,
|
||||
email: String? = nil,
|
||||
password: String
|
||||
) {
|
||||
self.username = username
|
||||
self.email = email
|
||||
self.password = password
|
||||
}
|
||||
}
|
||||
|
||||
struct Token: Codable, Equatable, Identifiable, Sendable {
|
||||
public let id: UUID
|
||||
public let userID: User.ID
|
||||
public let value: String
|
||||
|
||||
public init(
|
||||
id: UUID,
|
||||
userID: User.ID,
|
||||
value: String
|
||||
) {
|
||||
self.id = id
|
||||
self.userID = userID
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,23 +26,3 @@ public extension DatabaseClient {
|
||||
extension DatabaseClient.VendorBranches: TestDependencyKey {
|
||||
public static let testValue: DatabaseClient.VendorBranches = Self()
|
||||
}
|
||||
|
||||
public extension VendorBranch {
|
||||
struct Create: Codable, Sendable {
|
||||
public let name: String
|
||||
public let vendorID: Vendor.ID
|
||||
|
||||
public init(name: String, vendorID: Vendor.ID) {
|
||||
self.name = name
|
||||
self.vendorID = vendorID
|
||||
}
|
||||
}
|
||||
|
||||
struct Update: Codable, Sendable {
|
||||
public let name: String?
|
||||
|
||||
public init(name: String?) {
|
||||
self.name = name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,22 +34,3 @@ public extension DatabaseClient {
|
||||
extension DatabaseClient.Vendors: TestDependencyKey {
|
||||
public static let testValue: DatabaseClient.Vendors = Self()
|
||||
}
|
||||
|
||||
public extension Vendor {
|
||||
|
||||
struct Create: Codable, Sendable {
|
||||
public let name: String
|
||||
|
||||
public init(name: String) {
|
||||
self.name = name
|
||||
}
|
||||
}
|
||||
|
||||
struct Update: Codable, Sendable {
|
||||
public let name: String?
|
||||
|
||||
public init(name: String?) {
|
||||
self.name = name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user