Skip to content

Commit 5f4bde8

Browse files
authored
feat: Add strongly typed hook triggers (#39)
* feat: Add strongly typed hook triggers * add deprecations * update readme * Update versions * Update .codecov.yml
1 parent 9619d3c commit 5f4bde8

File tree

7 files changed

+866
-151
lines changed

7 files changed

+866
-151
lines changed

.codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ coverage:
44
status:
55
patch:
66
default:
7-
target: 46
7+
target: 17
88
changes: false
99
project:
1010
default:
11-
target: 43
11+
target: 38
1212
comment:
1313
require_changes: true

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
dependencies: [
1919
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.77.0")),
2020
.package(url: "https://github.com/netreconlab/Parse-Swift.git",
21-
.upToNextMajor(from: "5.7.3"))
21+
.upToNextMajor(from: "5.7.4"))
2222
],
2323
targets: [
2424
.target(

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ app.post("hello",
287287
```swift
288288
// A Parse Hook Trigger route.
289289
app.post("score", "save", "before",
290-
className: GameScore.className,
291-
triggerName: .beforeSave) { req async throws -> ParseHookResponse<GameScore> in
290+
object: GameScore.self,
291+
trigger: .beforeSave) { req async throws -> ParseHookResponse<GameScore> in
292292
// Note that `ParseHookResponse<GameScore>` means a "successfull"
293293
// response will return a "GameScore" type.
294294
if let error: ParseHookResponse<GameScore> = checkHeaders(req) {
@@ -315,8 +315,8 @@ app.post("score", "save", "before",
315315

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

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

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

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

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

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

426426
// Another Parse Hook Trigger route for `ParseLiveQuery`.
427427
app.post("score", "event", "after",
428-
className: GameScore.className,
429-
triggerName: .afterEvent) { req async throws -> ParseHookResponse<Bool> in
428+
object: GameScore.self,
429+
trigger: .afterEvent) { req async throws -> ParseHookResponse<Bool> in
430430
// Note that `ParseHookResponse<Bool>` means a "successfull"
431431
// response will return a "Bool" type. Bool is the standard response with
432432
// a "true" response meaning everything is okay or continue.

Sources/ParseServerSwift/Extensions/Parse+Vapor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public extension ParseHookRequestable {
4747
// swiftlint:disable:next line_length
4848
parseServerURLStrings: [String] = ParseServerSwift.configuration.parseServerURLStrings) async throws -> Self {
4949
var updatedOptions = try self.options(request, parseServerURLStrings: parseServerURLStrings)
50-
updatedOptions = updatedOptions.union(options)
50+
updatedOptions = options.union(updatedOptions)
5151
return try await withCheckedThrowingContinuation { continuation in
5252
self.hydrateUser(options: updatedOptions,
5353
completion: continuation.resume)

0 commit comments

Comments
 (0)