Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 109 additions & 82 deletions Package.resolved

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
// swift-tools-version:5.10
// swift-tools-version:6.0
import PackageDescription

let package = Package(
name: "swift-leeds",
platforms: [
.macOS(.v12),
.macOS(.v13),
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/leaf.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),
.package(url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "4.7.0"),
.package(url: "https://github.com/vapor/apns.git", from: "1.0.0"),
.package(url: "https://github.com/vapor/apns.git", from: "5.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"),
.package(url: "https://github.com/handya/markdown.git", branch: "fix/xcode-16"),

// This package is used by AWSSDKSwiftCore on Linux only. We add it here (but don't utilise it) in order to
// add it to the Package.resolved file. This ensures that when Docker or Heroku resolves this project, it will not
// ignore the versions pinned (causing a disparity between production Linux releases and local macOS builds).
// add it to the Package.resolved file. This ensures that when Docker resolves this project, it will not ignore
// the versions pinned (causing a disparity between production Linux releases and local macOS builds). This also
// massively improves build times by preventing multiple resolution cycles on deploy.
.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"),
],
targets: [
Expand All @@ -31,7 +32,7 @@ let package = Package(
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
.product(name: "S3", package: "aws-sdk-swift"),
.product(name: "SwiftMarkdown", package: "markdown"),
.product(name: "APNS", package: "apns"),
.product(name: "VaporAPNS", package: "apns"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
],
Expand All @@ -41,14 +42,13 @@ let package = Package(
name: "AppTests",
dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
.product(name: "VaporTesting", package: "vapor"),
],
swiftSettings: swiftSettings
),
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency"),
.enableUpcomingFeature("ExistentialAny"),
] }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Fluent
import Vapor

struct ActivityRouteController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
// Modal
routes.get(use: onRead)
routes.get(":id", use: onRead)
Expand All @@ -21,7 +21,7 @@ struct ActivityRouteController: RouteCollection {
return try await request.view.render("Admin/Form/activity_form", context)
}

private func buildContext(from db: Database, activity: Activity?) async throws -> ActivityContext {
private func buildContext(from db: any Database, activity: Activity?) async throws -> ActivityContext {
let events = try await Event.query(on: db).sort(\.$date).all()
return ActivityContext(activity: activity, events: events)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class ActivityMigrationV1: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.activity)
.id()
.field("title", .string, .required)
Expand All @@ -13,7 +13,7 @@ final class ActivityMigrationV1: AsyncMigration {
.create()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.activity).delete()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
import Vapor

struct AuthController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
routes.get("logout", use: logout)
let grouped = routes.grouped("api", "v1", "auth")
grouped.post("create", use: create)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class UserMigrationV1: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.user)
.id()
.field("name", .string, .required)
Expand All @@ -12,7 +12,7 @@ final class UserMigrationV1: AsyncMigration {
.create()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.user).delete()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

struct UserTokenMigrationV1: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.userToken)
.id()
.field("value", .string, .required)
Expand All @@ -12,7 +12,7 @@ struct UserTokenMigrationV1: AsyncMigration {
.create()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.userToken).delete()
}
}
10 changes: 5 additions & 5 deletions Sources/App/Features/Auth/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ final class User: Authenticatable, ModelAuthenticatable, Content, ModelSessionAu
return id ?? .init()
}

static let usernameKey = \User.$email
static let passwordHashKey = \User.$passwordHash
static var usernameKey: KeyPath<User, Field<String>> { \User.$email }
static var passwordHashKey: KeyPath<User, Field<String>> { \User.$passwordHash }

// Unique identifier for this user.
@ID()
Expand Down Expand Up @@ -64,19 +64,19 @@ final class User: Authenticatable, ModelAuthenticatable, Content, ModelSessionAu

public static func credentialsAuthenticator(
database _: DatabaseID? = nil
) -> Authenticator {
) -> any Authenticator {
return CustomCredentialsAuthenticator()
}

public static func sessionAuthenticator(
_: DatabaseID? = nil
) -> Authenticator {
) -> any Authenticator {
return SessionAuthenticator()
}

public static func authenticator(
database _: DatabaseID? = nil
) -> Authenticator {
) -> any Authenticator {
return BearerAuthenticatable()
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/App/Features/Auth/Models/UserToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ final class UserToken: Model, Content, ModelTokenAuthenticatable, Codable, @unch

typealias User = App.User

static let valueKey = \UserToken.$value
static let userKey = \UserToken.$user
static var valueKey: KeyPath<UserToken, Field<String>> { \UserToken.$value }
static var userKey: KeyPath<UserToken, Parent<User>> { \UserToken.$user }

var isValid: Bool {
return timestamp > Date()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vapor

struct CheckInAPIController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
routes.get(":secret", use: onGet)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct DropInRouteController: RouteCollection {
let sessions: [DropInSession]
}

func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
// Modal
routes.get(use: onRead)
routes.get(":id", use: onRead)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class AddDropInGroupsMigration: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.dropInSessions)
.field("max_tickets", .int, .sql(.default(1)), .required)
.field("exclusivity_key", .string, .sql(.default("A")), .required)
Expand All @@ -11,7 +11,7 @@ final class AddDropInGroupsMigration: AsyncMigration {
.update()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.dropInSessions)
.deleteField("max_tickets")
.deleteField("exclusivity_key")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class AddDropInSessionMigration: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.dropInSessions)
.id()
.field("title", .string, .required)
Expand All @@ -13,7 +13,7 @@ final class AddDropInSessionMigration: AsyncMigration {
.create()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.dropInSessions).delete()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class AddDropInSessionSlotsMigration: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.dropInSessionSlots)
.id()
.field("session_id", .uuid, .references(Schema.dropInSessions, "id"))
Expand All @@ -11,7 +11,7 @@ final class AddDropInSessionSlotsMigration: AsyncMigration {
.create()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.dropInSessionSlots).delete()
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Fluent

final class AddDropInTBAMigration: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.dropInSessions)
.field("is_public", .bool, .sql(.default(false)), .required) // default to hidden
.update()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.dropInSessions)
.deleteField("is_public")
.update()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Fluent

final class AddDurationToDropInMigration: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.dropInSessionSlots)
.field("duration", .int, .sql(.default(15)), .required)
.update()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.dropInSessionSlots)
.deleteField("duration")
.update()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class UseArrayDropInOwnerMigration: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
// I'll be honest, I tried so many ways to get this to be a non-breaking change... but I couldn't get it to work
// So it's a destructive update and I've manually fixed production (James Sherlock - May 31st 2024)
try await database.schema(Schema.dropInSessionSlots)
Expand All @@ -12,7 +12,7 @@ final class UseArrayDropInOwnerMigration: AsyncMigration {
.update()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
// Note, this is a destructive change and all data will be lost.
try await database.schema(Schema.dropInSessionSlots)
.deleteField("ticket")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LeafKit
import Vapor

struct EventDayRouteController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
// Modal
routes.get(use: onRead)
routes.get(":id", use: onRead)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import Fluent

final class EventDayMigrationV1: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.eventDay)
.id()
.field("event_id", .uuid, .required, .references(Schema.event, "id"))
Expand All @@ -14,7 +14,7 @@ final class EventDayMigrationV1: AsyncMigration {

// We use this local-only model (instead of the 'real' Slot) to solve a migration step problem,
// whilst also allowing us to drop event and date from Slot
final class MigrationSlot: Model {
final class MigrationSlot: Model, @unchecked Sendable {
static let schema = Schema.slot

@ID(key: .id) var id: UUID?
Expand Down Expand Up @@ -47,7 +47,7 @@ final class EventDayMigrationV1: AsyncMigration {
}
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.eventDay).delete()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LeafKit
import Vapor

struct EventRouteController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
// Modal
routes.get(use: onRead)
routes.get(":id", use: onRead)
Expand Down
2 changes: 1 addition & 1 deletion Sources/App/Features/Events/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class Event: Model, Content, @unchecked Sendable {
}

extension Event {
static func getCurrent(on db: Database) async throws -> Event {
static func getCurrent(on db: any Database) async throws -> Event {
guard let event = try await Event.query(on: db).filter(\.$isCurrent == true).first() else {
throw Abort(.notFound, reason: "could not locate current event")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Fluent

final class EventMigrationV1: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.event)
.id()
.field("name", .string, .required)
Expand All @@ -10,7 +10,7 @@ final class EventMigrationV1: AsyncMigration {
.create()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.event).delete()
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Fluent

final class EventMigrationV2: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema(Schema.event)
.field("is_current", .bool, .sql(.default(false)), .required)
.update()
}

func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema(Schema.event)
.deleteField("is_current")
.update()
Expand Down
Loading
Loading