Skip to content

Commit

Permalink
feat: Add strongly typed hook triggers (#39)
Browse files Browse the repository at this point in the history
* feat: Add strongly typed hook triggers

* add deprecations

* update readme

* Update versions

* Update .codecov.yml
  • Loading branch information
cbaker6 committed Jun 23, 2023
1 parent 9619d3c commit 5f4bde8
Show file tree
Hide file tree
Showing 7 changed files with 866 additions and 151 deletions.
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ coverage:
status:
patch:
default:
target: 46
target: 17
changes: false
project:
default:
target: 43
target: 38
comment:
require_changes: true
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/netreconlab/Parse-Swift.git",
"state" : {
"revision" : "df20af5bdcbe349ffd65ad3626c86bddb1cfdd37",
"version" : "5.7.3"
"revision" : "835083e870b20a7a999b49e5ed3f57c0dc442e89",
"version" : "5.7.4"
}
},
{
Expand Down Expand Up @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "34025104068262db0cc998ace178975c5ff4f36b",
"version" : "2.4.0"
"revision" : "971ba26378ab69c43737ee7ba967a896cb74c0d1",
"version" : "2.4.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.77.0")),
.package(url: "https://github.com/netreconlab/Parse-Swift.git",
.upToNextMajor(from: "5.7.3"))
.upToNextMajor(from: "5.7.4"))
],
targets: [
.target(
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ app.post("hello",
```swift
// A Parse Hook Trigger route.
app.post("score", "save", "before",
className: GameScore.className,
triggerName: .beforeSave) { req async throws -> ParseHookResponse<GameScore> in
object: GameScore.self,
trigger: .beforeSave) { req async throws -> ParseHookResponse<GameScore> in
// Note that `ParseHookResponse<GameScore>` means a "successfull"
// response will return a "GameScore" type.
if let error: ParseHookResponse<GameScore> = checkHeaders(req) {
Expand All @@ -315,8 +315,8 @@ app.post("score", "save", "before",

// Another Parse Hook Trigger route.
app.post("score", "find", "before",
className: GameScore.className,
triggerName: .beforeFind) { req async throws -> ParseHookResponse<[GameScore]> in
object: GameScore.self,
trigger: .beforeFind) { req async throws -> ParseHookResponse<[GameScore]> in
// Note that `ParseHookResponse<[GameScore]>` means a "successfull"
// response will return a "[GameScore]" type.
if let error: ParseHookResponse<[GameScore]> = checkHeaders(req) {
Expand All @@ -342,8 +342,8 @@ app.post("score", "find", "before",

// Another Parse Hook Trigger route.
app.post("user", "login", "after",
className: User.className,
triggerName: .afterLogin) { req async throws -> ParseHookResponse<Bool> in
object: User.self,
trigger: .afterLogin) { req async throws -> ParseHookResponse<Bool> in
// Note that `ParseHookResponse<Bool>` means a "successfull"
// response will return a "Bool" type. Bool is the standard response with
// a "true" response meaning everything is okay or continue.
Expand All @@ -359,7 +359,7 @@ app.post("user", "login", "after",

// A Parse Hook Trigger route for `ParseFile`.
app.on("file", "save", "before",
triggerName: .beforeSave) { req async throws -> ParseHookResponse<Bool> in
trigger: .beforeSave) { req async throws -> ParseHookResponse<Bool> in
// Note that `ParseHookResponse<Bool>` means a "successfull"
// response will return a "Bool" type. Bool is the standard response with
// a "true" response meaning everything is okay or continue. Sending "false"
Expand All @@ -376,7 +376,7 @@ app.on("file", "save", "before",

// Another Parse Hook Trigger route for `ParseFile`.
app.post("file", "delete", "before",
triggerName: .beforeDelete) { req async throws -> ParseHookResponse<Bool> in
trigger: .beforeDelete) { req async throws -> ParseHookResponse<Bool> in
// Note that `ParseHookResponse<Bool>` means a "successfull"
// response will return a "Bool" type. Bool is the standard response with
// a "true" response meaning everything is okay or continue.
Expand All @@ -392,7 +392,7 @@ app.post("file", "delete", "before",

// A Parse Hook Trigger route for `ParseLiveQuery`.
app.post("connect", "before",
triggerName: .beforeConnect) { req async throws -> ParseHookResponse<Bool> in
trigger: .beforeConnect) { req async throws -> ParseHookResponse<Bool> in
// Note that `ParseHookResponse<Bool>` means a "successfull"
// response will return a "Bool" type. Bool is the standard response with
// a "true" response meaning everything is okay or continue.
Expand All @@ -408,8 +408,8 @@ app.post("connect", "before",

// Another Parse Hook Trigger route for `ParseLiveQuery`.
app.post("score", "subscribe", "before",
className: GameScore.className,
triggerName: .beforeSubscribe) { req async throws -> ParseHookResponse<Bool> in
object: GameScore.self,
trigger: .beforeSubscribe) { req async throws -> ParseHookResponse<Bool> in
// Note that `ParseHookResponse<Bool>` means a "successfull"
// response will return a "Bool" type. Bool is the standard response with
// a "true" response meaning everything is okay or continue.
Expand All @@ -425,8 +425,8 @@ app.post("score", "subscribe", "before",

// Another Parse Hook Trigger route for `ParseLiveQuery`.
app.post("score", "event", "after",
className: GameScore.className,
triggerName: .afterEvent) { req async throws -> ParseHookResponse<Bool> in
object: GameScore.self,
trigger: .afterEvent) { req async throws -> ParseHookResponse<Bool> in
// Note that `ParseHookResponse<Bool>` means a "successfull"
// response will return a "Bool" type. Bool is the standard response with
// a "true" response meaning everything is okay or continue.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseServerSwift/Extensions/Parse+Vapor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public extension ParseHookRequestable {
// swiftlint:disable:next line_length
parseServerURLStrings: [String] = ParseServerSwift.configuration.parseServerURLStrings) async throws -> Self {
var updatedOptions = try self.options(request, parseServerURLStrings: parseServerURLStrings)
updatedOptions = updatedOptions.union(options)
updatedOptions = options.union(updatedOptions)
return try await withCheckedThrowingContinuation { continuation in
self.hydrateUser(options: updatedOptions,
completion: continuation.resume)
Expand Down
Loading

0 comments on commit 5f4bde8

Please sign in to comment.