@@ -50,13 +50,17 @@ extension HookFunction {
50
50
. delete ( options: [ . serverURL( parseServerURLString) ] )
51
51
default :
52
52
throw ParseError ( code: . otherCause,
53
+ // swiftlint:disable:next line_length
53
54
message: " Method \( method) is not supported for Hook Function: \" \( String ( describing: hookFunction) ) \" " )
54
55
}
56
+ // swiftlint:disable:next line_length
55
57
configuration. logger. notice ( " Successful \( method) ; Hook Function: \" \( String ( describing: hookFunction) ) \" on server: \( parseServerURLString) " )
56
58
} catch {
57
59
if error. containedIn ( [ . webhookError] ) && method == . POST {
60
+ // swiftlint:disable:next line_length
58
61
configuration. logger. warning ( " Hook Function: \" \( String ( describing: hookFunction) ) \" ; warning: \( error) ; on server: \( parseServerURLString) " )
59
62
} else {
63
+ // swiftlint:disable:next line_length
60
64
configuration. logger. error ( " Could not \( method) Hook Function: \" \( String ( describing: hookFunction) ) \" ; error: \( error) ; on server: \( parseServerURLString) " )
61
65
}
62
66
}
@@ -68,7 +72,7 @@ extension HookFunction {
68
72
69
73
// MARK: HookFunction - Fetch
70
74
public extension HookFunction {
71
-
75
+
72
76
/**
73
77
Fetches a Parse Cloud Code hook function.
74
78
- parameter path: A variadic list of paths.
@@ -80,8 +84,8 @@ public extension HookFunction {
80
84
Will log an error for each `parseServerURLString` that returns an error.
81
85
*/
82
86
static func fetch( _ path: PathComponent ... ,
83
- name: String ,
84
- parseServerURLStrings: [ String ] ) async throws -> [ String : HookFunction ] {
87
+ name: String ,
88
+ parseServerURLStrings: [ String ] ) async throws -> [ String : HookFunction ] {
85
89
try await fetch ( path, name: name, parseServerURLStrings: parseServerURLStrings)
86
90
}
87
91
@@ -96,11 +100,11 @@ public extension HookFunction {
96
100
Will log an error for each `parseServerURLString` that returns an error.
97
101
*/
98
102
static func fetch( _ path: [ PathComponent ] ,
99
- name: String ,
100
- parseServerURLStrings: [ String ] ) async throws -> [ String : HookFunction ] {
103
+ name: String ,
104
+ parseServerURLStrings: [ String ] ) async throws -> [ String : HookFunction ] {
101
105
try await method ( . PUT, path, name: name, parseServerURLStrings: parseServerURLStrings)
102
106
}
103
-
107
+
104
108
/**
105
109
Fetches all Parse Cloud Code hook function.
106
110
- parameter path: A variadic list of paths.
@@ -140,6 +144,7 @@ public extension HookFunction {
140
144
hookFunctions [ parseServerURLString] = try await hookFunction
141
145
. fetchAll ( options: [ . serverURL( parseServerURLString) ] )
142
146
} catch {
147
+ // swiftlint:disable:next line_length
143
148
configuration. logger. error ( " Could not fetchAll function: \" \( String ( describing: hookFunction) ) \" ; error: \( error) ; on server: \( parseServerURLString) " )
144
149
}
145
150
}
@@ -149,7 +154,7 @@ public extension HookFunction {
149
154
150
155
// MARK: HookFunction - Create
151
156
public extension HookFunction {
152
-
157
+
153
158
/**
154
159
Creates a Parse Cloud Code hook function.
155
160
- parameter path: A variadic list of paths.
@@ -163,6 +168,7 @@ public extension HookFunction {
163
168
*/
164
169
static func create( _ path: PathComponent ... ,
165
170
name: String ,
171
+ // swiftlint:disable:next line_length
166
172
parseServerURLStrings: [ String ] = ParseServerSwift . configuration. parseServerURLStrings) async throws -> [ String : HookFunction ] {
167
173
try await create ( path, name: name, parseServerURLStrings: parseServerURLStrings)
168
174
}
@@ -180,14 +186,15 @@ public extension HookFunction {
180
186
*/
181
187
static func create( _ path: [ PathComponent ] ,
182
188
name: String ,
189
+ // swiftlint:disable:next line_length
183
190
parseServerURLStrings: [ String ] = ParseServerSwift . configuration. parseServerURLStrings) async throws -> [ String : HookFunction ] {
184
191
try await method ( . POST, path, name: name, parseServerURLStrings: parseServerURLStrings)
185
192
}
186
193
}
187
194
188
195
// MARK: HookFunction - Update
189
196
public extension HookFunction {
190
-
197
+
191
198
/**
192
199
Updates a Parse Cloud Code hook function.
193
200
- parameter path: A variadic list of paths.
@@ -201,6 +208,7 @@ public extension HookFunction {
201
208
*/
202
209
static func update( _ path: PathComponent ... ,
203
210
name: String ,
211
+ // swiftlint:disable:next line_length
204
212
parseServerURLStrings: [ String ] = ParseServerSwift . configuration. parseServerURLStrings) async throws -> [ String : HookFunction ] {
205
213
try await update ( path, name: name, parseServerURLStrings: parseServerURLStrings)
206
214
}
@@ -218,14 +226,15 @@ public extension HookFunction {
218
226
*/
219
227
static func update( _ path: [ PathComponent ] ,
220
228
name: String ,
229
+ // swiftlint:disable:next line_length
221
230
parseServerURLStrings: [ String ] = ParseServerSwift . configuration. parseServerURLStrings) async throws -> [ String : HookFunction ] {
222
231
try await method ( . PUT, path, name: name, parseServerURLStrings: parseServerURLStrings)
223
232
}
224
233
}
225
234
226
235
// MARK: HookFunction - Delete
227
236
public extension HookFunction {
228
-
237
+
229
238
/**
230
239
Removes a Parse Cloud Code hook function.
231
240
- parameter path: A variadic list of paths.
@@ -238,6 +247,7 @@ public extension HookFunction {
238
247
*/
239
248
static func delete( _ path: PathComponent ... ,
240
249
name: String ,
250
+ // swiftlint:disable:next line_length
241
251
parseServerURLStrings: [ String ] = ParseServerSwift . configuration. parseServerURLStrings) async throws {
242
252
try await delete ( path, name: name, parseServerURLStrings: parseServerURLStrings)
243
253
}
@@ -254,6 +264,7 @@ public extension HookFunction {
254
264
*/
255
265
static func delete( _ path: [ PathComponent ] ,
256
266
name: String ,
267
+ // swiftlint:disable:next line_length
257
268
parseServerURLStrings: [ String ] = ParseServerSwift . configuration. parseServerURLStrings) async throws {
258
269
try await method ( . DELETE, path, name: name, parseServerURLStrings: parseServerURLStrings)
259
270
}
@@ -276,8 +287,7 @@ public extension RoutesBuilder {
276
287
name: String ,
277
288
use closure: @escaping ( Request ) async throws -> Response
278
289
) -> Route
279
- where Response: AsyncResponseEncodable
280
- {
290
+ where Response: AsyncResponseEncodable {
281
291
self . on ( path,
282
292
name: name,
283
293
use: closure)
@@ -298,8 +308,7 @@ public extension RoutesBuilder {
298
308
name: String ,
299
309
use closure: @escaping ( Request ) async throws -> Response
300
310
) -> Route
301
- where Response: AsyncResponseEncodable
302
- {
311
+ where Response: AsyncResponseEncodable {
303
312
self . on ( path,
304
313
name: name,
305
314
use: closure)
@@ -322,8 +331,7 @@ public extension RoutesBuilder {
322
331
name: String ,
323
332
use closure: @escaping ( Request ) async throws -> Response
324
333
) -> Route
325
- where Response: AsyncResponseEncodable
326
- {
334
+ where Response: AsyncResponseEncodable {
327
335
self . on ( path,
328
336
body: body,
329
337
name: name,
@@ -347,13 +355,13 @@ public extension RoutesBuilder {
347
355
name: String ,
348
356
use closure: @escaping ( Request ) async throws -> Response
349
357
) -> Route
350
- where Response: AsyncResponseEncodable
351
- {
358
+ where Response: AsyncResponseEncodable {
352
359
Task {
353
360
do {
354
361
await configuration. hooks. updateFunctions ( try await HookFunction . create ( path,
355
362
name: name) )
356
363
} catch {
364
+ // swiftlint:disable:next line_length
357
365
configuration. logger. error ( " Could not create HookFunction route for path: \( path) ; name: \( name) on servers: \( configuration. parseServerURLStrings) because of error: \( error) " )
358
366
}
359
367
}
0 commit comments