File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -28,16 +28,12 @@ extension VaporHandler {
2828 try await configure ( app: app)
2929 // Configure vercel server
3030 app. servers. use ( . vercel)
31- // Start the application
32- try await app. startup ( )
3331 // Cache the app instance
34- await MainActor . run {
35- Shared . app = app
36- }
32+ await Shared . default. setApp ( app)
3733 }
3834
3935 public func onRequest( _ req: Vercel . Request ) async throws -> Vercel . Response {
40- guard let app = await Shared . app else {
36+ guard let app = await Shared . default . app else {
4137 return . status( . serviceUnavailable) . send ( " Vapor application not configured " )
4238 }
4339 let vaporRequest = try Vapor . Request. from ( request: req, for: app)
@@ -46,10 +42,15 @@ extension VaporHandler {
4642 }
4743}
4844
49- private struct Shared {
45+ private actor Shared {
46+
47+ static let `default` = Shared ( )
5048
51- @MainActor
52- static var app : Application ?
49+ private( set) var app : Application ?
50+
51+ func setApp( _ app: Application ) {
52+ self . app = app
53+ }
5354}
5455
5556extension Vapor . Request {
You can’t perform that action at this time.
0 commit comments