feat: Begins moving models into their own module.
This commit is contained in:
38
Sources/SharedModels/User.swift
Normal file
38
Sources/SharedModels/User.swift
Normal file
@@ -0,0 +1,38 @@
|
||||
import Dependencies
|
||||
import Foundation
|
||||
|
||||
public struct User: Identifiable, Codable, Sendable {
|
||||
|
||||
public var id: UUID
|
||||
public var createdAt: Date
|
||||
public var email: String
|
||||
public var updatedAt: Date
|
||||
public var username: String
|
||||
|
||||
public init(
|
||||
id: UUID? = nil,
|
||||
createdAt: Date? = nil,
|
||||
email: String,
|
||||
updatedAt: Date? = nil,
|
||||
username: String
|
||||
) {
|
||||
@Dependency(\.date) var date
|
||||
@Dependency(\.uuid) var uuid
|
||||
|
||||
self.id = id ?? uuid()
|
||||
self.createdAt = createdAt ?? date()
|
||||
self.email = email
|
||||
self.updatedAt = updatedAt ?? date()
|
||||
self.username = username
|
||||
}
|
||||
}
|
||||
|
||||
public extension User {
|
||||
static var mocks: [Self] {
|
||||
[
|
||||
.init(email: "blob@test.com", username: "blob"),
|
||||
.init(email: "blob-jr@test.com", username: "blob-jr"),
|
||||
.init(email: "blob-sr@test.com", username: "blob-sr")
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user