Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async app lifecycle, strict concurrency prep check #15

Merged
merged 1 commit into from
May 29, 2024
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
94 changes: 47 additions & 47 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "d739504014ee5c8a0b279c240a2b0e96c5d9c509f970a6c7cd722fabaabba9cd",
"originHash" : "146fbe9062cb34b5fb31a0a4dd39b239846a1b80f91f61ba21c6f2b478afe617",
"pins" : [
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "291438696abdd48d2a83b52465c176efbd94512b",
"version" : "1.20.1"
"revision" : "a22083713ee90808d527d0baa290c2fb13ca3096",
"version" : "1.21.1"
}
},
{
Expand All @@ -24,8 +24,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/console-kit.git",
"state" : {
"revision" : "a31f44ebfbd15a2cc0fda705279676773ac16355",
"version" : "4.14.1"
"revision" : "9c24ac496c97cfb49c1bd5e7162008bb50abafc8",
"version" : "4.14.2"
}
},
{
Expand All @@ -51,26 +51,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/fluent.git",
"state" : {
"revision" : "a586a5d4164f23a0ee4e02e1f467b9bbef0c9f1c",
"version" : "4.9.0"
"revision" : "d831ac5e6a514dd8aa8d5499bb04be3983be1112",
"version" : "4.10.0"
}
},
{
"identity" : "fluent-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/fluent-kit.git",
"state" : {
"revision" : "5f0938a3f5f1a751ff7a411117bfce4efe713526",
"version" : "1.47.2"
"revision" : "cb91bf94fceedc6756e5b022ab394f6862154c34",
"version" : "1.48.4"
}
},
{
"identity" : "fluent-postgres-driver",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/fluent-postgres-driver.git",
"state" : {
"revision" : "a538fc647f82d915eb84e0a12ca9b08c513e57c4",
"version" : "2.8.0"
"revision" : "e2988a8c960196eca2891f3a0bb1caad9044e7ea",
"version" : "2.9.2"
}
},
{
Expand All @@ -87,62 +87,62 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/jwt-kit.git",
"state" : {
"revision" : "e05513b5aec24f88012b6e3034115b6bc915356a",
"version" : "4.13.2"
"revision" : "c2595b9ad7f512d7f334830b4df1fed6e917946a",
"version" : "4.13.4"
}
},
{
"identity" : "mixpanelvapor",
"kind" : "remoteSourceControl",
"location" : "https://github.com/petrpavlik/MixpanelVapor.git",
"state" : {
"revision" : "1413f86c8cd28fe846b0f5819316ea00d35816fd",
"version" : "0.3.0"
"revision" : "7f18c3a7b270391d2ea51ea87a56eef0d60134d2",
"version" : "1.0.0"
}
},
{
"identity" : "multipart-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/multipart-kit.git",
"state" : {
"revision" : "12ee56f25bd3fc4c2d09c2aa16e69de61dc786e8",
"version" : "4.6.0"
"revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68",
"version" : "4.7.0"
}
},
{
"identity" : "nimble",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "efe11bbca024b57115260709b5c05e01131470d0",
"version" : "13.2.1"
"revision" : "1c49fc1243018f81a7ea99cb5e0985b00096e9f4",
"version" : "13.3.0"
}
},
{
"identity" : "postgres-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/postgres-kit.git",
"state" : {
"revision" : "e26763a6cb8d852f7ce01b1cd5925b3d8d084801",
"version" : "2.13.1"
"revision" : "0b72fa83b1023c4b82072e4049a3db6c29781fff",
"version" : "2.13.5"
}
},
{
"identity" : "postgres-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/postgres-nio.git",
"state" : {
"revision" : "e345cbb9cf6052b37b27c0c4f976134fc01dbe15",
"version" : "1.21.1"
"revision" : "d3795844d488210b65ace34c5f003e47d812d999",
"version" : "1.21.3"
}
},
{
"identity" : "routing-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/routing-kit.git",
"state" : {
"revision" : "2a92a7eac411a82fb3a03731be5e76773ebe1b3e",
"version" : "4.9.0"
"revision" : "8c9a227476555c55837e569be71944e02a056b72",
"version" : "4.9.1"
}
},
{
Expand All @@ -159,8 +159,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/sql-kit.git",
"state" : {
"revision" : "b2f128cb62a3abfbb1e3b2893ff3ee69e70f4f0f",
"version" : "3.28.0"
"revision" : "25d8170c31173c7db4ddfef473e257c3bde60783",
"version" : "3.30.0"
}
},
{
Expand Down Expand Up @@ -204,17 +204,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb",
"version" : "3.3.0"
"revision" : "bc1c29221f6dfeb0ebbfbc98eb95cd3d4967868e",
"version" : "3.4.0"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "12358d55a3824bd5fed310b999ea8cf83a9a1a65",
"version" : "1.0.3"
"revision" : "9bee2fdb79cc740081abd8ebd80738063d632286",
"version" : "1.1.0"
}
},
{
Expand All @@ -231,17 +231,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "971ba26378ab69c43737ee7ba967a896cb74c0d1",
"version" : "2.4.1"
"revision" : "ce594e71e92a1610015017f83f402894df540e51",
"version" : "2.4.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982",
"version" : "2.64.0"
"revision" : "359c461e5561d22c6334828806cc25d759ca7aa6",
"version" : "2.65.0"
}
},
{
Expand All @@ -258,8 +258,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "0904bf0feb5122b7e5c3f15db7df0eabe623dd87",
"version" : "1.30.0"
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
Expand All @@ -276,8 +276,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce",
"version" : "1.20.1"
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
"version" : "1.21.0"
}
},
{
Expand All @@ -294,26 +294,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/petrpavlik/swift-sentry.git",
"state" : {
"branch" : "main",
"revision" : "2bc05a18f20fcf124520f078b57a58e6c6f077c5"
"revision" : "de65bc412272b307e7d0b0f28e2d578cd1f0c811",
"version" : "1.0.0"
}
},
{
"identity" : "swift-service-lifecycle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/swift-service-lifecycle.git",
"state" : {
"revision" : "d7fe0e731499a8dcce53bf4cbbc812c8e565d3a7",
"version" : "2.4.1"
"revision" : "12a031bcc1284c64d6b847f5013ffe6dcca964d0",
"version" : "2.5.0"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
"version" : "1.2.1"
"revision" : "f9266c85189c2751589a50ea5aec72799797e471",
"version" : "1.3.0"
}
},
{
Expand All @@ -330,8 +330,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "11cdb29614a5c7f8c5289f3c97b3398c3d89b395",
"version" : "4.92.5"
"revision" : "12e9b41cc576165150cb236676fc94d997d3db5f",
"version" : "4.101.1"
}
},
{
Expand Down
17 changes: 13 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ let package = Package(
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.7.2"),
.package(url: "https://github.com/emvakar/vapor-firebase-jwt-middleware.git", branch: "master"),
.package(url: "https://github.com/Quick/Nimble.git", from: "13.0.0"),
.package(url: "https://github.com/petrpavlik/swift-sentry.git", branch: "main"),
.package(url: "https://github.com/petrpavlik/MixpanelVapor.git", from: "0.0.0"),
.package(url: "https://github.com/petrpavlik/swift-sentry.git", from: "1.0.0"),
.package(url: "https://github.com/petrpavlik/MixpanelVapor.git", from: "1.0.0"),
.package(url: "https://github.com/Joannis/VaporSMTPKit.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"),
],
targets: [
.executableTarget(
Expand All @@ -30,12 +31,20 @@ let package = Package(
.product(name: "SwiftSentry", package: "swift-sentry"),
"MixpanelVapor",
.product(name: "VaporSMTPKit", package: "VaporSMTPKit"),
]
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
],
swiftSettings: swiftSettings
),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
.product(name: "Nimble", package: "Nimble"),
])
], swiftSettings: swiftSettings)
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency"),
] }
8 changes: 8 additions & 0 deletions Sources/App/Controllers/OrganizationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct OrganizationController: RouteCollection {
}
}

@Sendable
func index(req: Request) async throws -> [OrganizationDTO] {
let profile = try await req.profile
try await profile.$organizations.load(on: req.db)
Expand All @@ -130,11 +131,13 @@ struct OrganizationController: RouteCollection {
.map({ try $0.toDTO() })
}

@Sendable
func get(req: Request) async throws -> OrganizationDTO {
let organization = try await req.organization(minRole: .lurker)
return try organization.toDTO()
}

@Sendable
func create(req: Request) async throws -> OrganizationDTO {
let profile = try await req.profile

Expand Down Expand Up @@ -171,6 +174,7 @@ struct OrganizationController: RouteCollection {
return try organization.toDTO()
}

@Sendable
func patch(req: Request) async throws -> OrganizationDTO {

let organization = try await req.organization(minRole: .admin)
Expand Down Expand Up @@ -201,6 +205,7 @@ struct OrganizationController: RouteCollection {
return try organization.toDTO()
}

@Sendable
func delete(req: Request) async throws -> HTTPStatus {
let profile = try await req.profile

Expand Down Expand Up @@ -234,6 +239,7 @@ struct OrganizationController: RouteCollection {
return .noContent
}

@Sendable
func putOrganizationMembership(req: Request) async throws -> OrganizationMemberDTO {

let profile = try await req.profile
Expand Down Expand Up @@ -361,6 +367,7 @@ struct OrganizationController: RouteCollection {
}
}

@Sendable
func deleteOrganizationMembership(req: Request) async throws -> HTTPStatus {

let profile = try await req.profile
Expand Down Expand Up @@ -409,6 +416,7 @@ struct OrganizationController: RouteCollection {
return .noContent
}

@Sendable
func listOrganizationMemberships(req: Request) async throws -> [OrganizationMemberDTO] {
let organization = try await req.organization(minRole: .lurker)
let organizationId = try organization.requireID()
Expand Down
Loading
Loading