@@ -2,7 +2,7 @@ import Vapor
2
2
import ParseSwift
3
3
4
4
// swiftlint:disable:next cyclomatic_complexity function_body_length
5
- func routes ( _ app: Application ) throws {
5
+ public func exampleRoutes ( _ app: Application ) throws {
6
6
7
7
// A typical route in Vapor.
8
8
app. get { req in
@@ -15,8 +15,10 @@ func routes(_ app: Application) throws {
15
15
}
16
16
17
17
// A simple Parse Hook Function route that returns "Hello World".
18
- app. post ( " hello " ,
19
- name: " hello " ) { req async throws -> ParseHookResponse < String > in
18
+ app. post (
19
+ " hello " ,
20
+ name: " hello "
21
+ ) { req async throws -> ParseHookResponse < String > in
20
22
// Note that `ParseHookResponse<String>` means a "successful"
21
23
// response will return a "String" type.
22
24
if let error: ParseHookResponse < String > = checkHeaders ( req) {
@@ -39,8 +41,10 @@ func routes(_ app: Application) throws {
39
41
}
40
42
41
43
// Another simple Parse Hook Function route that returns the version of the server.
42
- app. post ( " version " ,
43
- name: " version " ) { req async throws -> ParseHookResponse < String > in
44
+ app. post (
45
+ " version " ,
46
+ name: " version "
47
+ ) { req async throws -> ParseHookResponse < String > in
44
48
// Note that `ParseHookResponse<String>` means a "successful"
45
49
// response will return a "String" type.
46
50
if let error: ParseHookResponse < String > = checkHeaders ( req) {
@@ -89,9 +93,13 @@ func routes(_ app: Application) throws {
89
93
}
90
94
91
95
// A Parse Hook Trigger route.
92
- app. post ( " score " , " save " , " before " ,
93
- object: GameScore . self,
94
- trigger: . beforeSave) { req async throws -> ParseHookResponse < GameScore > in
96
+ app. post (
97
+ " score " ,
98
+ " save " ,
99
+ " before " ,
100
+ object: GameScore . self,
101
+ trigger: . beforeSave
102
+ ) { req async throws -> ParseHookResponse < GameScore > in
95
103
// Note that `ParseHookResponse<GameScore>` means a "successful"
96
104
// response will return a "GameScore" type.
97
105
if let error: ParseHookResponse < GameScore > = checkHeaders ( req) {
@@ -117,9 +125,13 @@ func routes(_ app: Application) throws {
117
125
}
118
126
119
127
// Another Parse Hook Trigger route.
120
- app. post ( " score " , " find " , " before " ,
121
- object: GameScore . self,
122
- trigger: . beforeFind) { req async throws -> ParseHookResponse < [ GameScore ] > in
128
+ app. post (
129
+ " score " ,
130
+ " find " ,
131
+ " before " ,
132
+ object: GameScore . self,
133
+ trigger: . beforeFind
134
+ ) { req async throws -> ParseHookResponse < [ GameScore ] > in
123
135
// Note that `ParseHookResponse<[GameScore]>` means a "successful"
124
136
// response will return a "[GameScore]" type.
125
137
if let error: ParseHookResponse < [ GameScore ] > = checkHeaders ( req) {
@@ -144,9 +156,13 @@ func routes(_ app: Application) throws {
144
156
}
145
157
146
158
// Another Parse Hook Trigger route.
147
- app. post ( " user " , " login " , " after " ,
148
- object: User . self,
149
- trigger: . afterLogin) { req async throws -> ParseHookResponse < Bool > in
159
+ app. post (
160
+ " user " ,
161
+ " login " ,
162
+ " after " ,
163
+ object: User . self,
164
+ trigger: . afterLogin
165
+ ) { req async throws -> ParseHookResponse < Bool > in
150
166
// Note that `ParseHookResponse<Bool>` means a "successful"
151
167
// response will return a "Bool" type. Bool is the standard response with
152
168
// a "true" response meaning everything is okay or continue.
@@ -161,8 +177,12 @@ func routes(_ app: Application) throws {
161
177
}
162
178
163
179
// A Parse Hook Trigger route for `ParseFile`.
164
- app. on ( " file " , " save " , " before " ,
165
- trigger: . beforeSave) { req async throws -> ParseHookResponse < Bool > in
180
+ app. on (
181
+ " file " ,
182
+ " save " ,
183
+ " before " ,
184
+ trigger: . beforeSave
185
+ ) { req async throws -> ParseHookResponse < Bool > in
166
186
// Note that `ParseHookResponse<Bool>` means a "successful"
167
187
// response will return a "Bool" type. Bool is the standard response with
168
188
// a "true" response meaning everything is okay or continue. Sending "false"
@@ -178,8 +198,12 @@ func routes(_ app: Application) throws {
178
198
}
179
199
180
200
// Another Parse Hook Trigger route for `ParseFile`.
181
- app. post ( " file " , " delete " , " before " ,
182
- trigger: . beforeDelete) { req async throws -> ParseHookResponse < Bool > in
201
+ app. post (
202
+ " file " ,
203
+ " delete " ,
204
+ " before " ,
205
+ trigger: . beforeDelete
206
+ ) { req async throws -> ParseHookResponse < Bool > in
183
207
// Note that `ParseHookResponse<Bool>` means a "successful"
184
208
// response will return a "Bool" type. Bool is the standard response with
185
209
// a "true" response meaning everything is okay or continue.
@@ -194,8 +218,11 @@ func routes(_ app: Application) throws {
194
218
}
195
219
196
220
// A Parse Hook Trigger route for `ParseLiveQuery`.
197
- app. post ( " connect " , " before " ,
198
- trigger: . beforeConnect) { req async throws -> ParseHookResponse < Bool > in
221
+ app. post (
222
+ " connect " ,
223
+ " before " ,
224
+ trigger: . beforeConnect
225
+ ) { req async throws -> ParseHookResponse < Bool > in
199
226
// Note that `ParseHookResponse<Bool>` means a "successful"
200
227
// response will return a "Bool" type. Bool is the standard response with
201
228
// a "true" response meaning everything is okay or continue.
@@ -210,9 +237,13 @@ func routes(_ app: Application) throws {
210
237
}
211
238
212
239
// Another Parse Hook Trigger route for `ParseLiveQuery`.
213
- app. post ( " score " , " subscribe " , " before " ,
214
- object: GameScore . self,
215
- trigger: . beforeSubscribe) { req async throws -> ParseHookResponse < Bool > in
240
+ app. post (
241
+ " score " ,
242
+ " subscribe " ,
243
+ " before " ,
244
+ object: GameScore . self,
245
+ trigger: . beforeSubscribe
246
+ ) { req async throws -> ParseHookResponse < Bool > in
216
247
// Note that `ParseHookResponse<Bool>` means a "successful"
217
248
// response will return a "Bool" type. Bool is the standard response with
218
249
// a "true" response meaning everything is okay or continue.
@@ -227,9 +258,13 @@ func routes(_ app: Application) throws {
227
258
}
228
259
229
260
// Another Parse Hook Trigger route for `ParseLiveQuery`.
230
- app. post ( " score " , " event " , " after " ,
231
- object: GameScore . self,
232
- trigger: . afterEvent) { req async throws -> ParseHookResponse < Bool > in
261
+ app. post (
262
+ " score " ,
263
+ " event " ,
264
+ " after " ,
265
+ object: GameScore . self,
266
+ trigger: . afterEvent
267
+ ) { req async throws -> ParseHookResponse < Bool > in
233
268
// Note that `ParseHookResponse<Bool>` means a "successful"
234
269
// response will return a "Bool" type. Bool is the standard response with
235
270
// a "true" response meaning everything is okay or continue.
0 commit comments