@@ -2,7 +2,7 @@ import Vapor
22import ParseSwift
33
44// swiftlint:disable:next cyclomatic_complexity function_body_length
5- func routes ( _ app: Application ) throws {
5+ public func exampleRoutes ( _ app: Application ) throws {
66
77 // A typical route in Vapor.
88 app. get { req in
@@ -15,8 +15,10 @@ func routes(_ app: Application) throws {
1515 }
1616
1717 // 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
2022 // Note that `ParseHookResponse<String>` means a "successful"
2123 // response will return a "String" type.
2224 if let error: ParseHookResponse < String > = checkHeaders ( req) {
@@ -39,8 +41,10 @@ func routes(_ app: Application) throws {
3941 }
4042
4143 // 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
4448 // Note that `ParseHookResponse<String>` means a "successful"
4549 // response will return a "String" type.
4650 if let error: ParseHookResponse < String > = checkHeaders ( req) {
@@ -89,9 +93,13 @@ func routes(_ app: Application) throws {
8993 }
9094
9195 // 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
95103 // Note that `ParseHookResponse<GameScore>` means a "successful"
96104 // response will return a "GameScore" type.
97105 if let error: ParseHookResponse < GameScore > = checkHeaders ( req) {
@@ -117,9 +125,13 @@ func routes(_ app: Application) throws {
117125 }
118126
119127 // 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
123135 // Note that `ParseHookResponse<[GameScore]>` means a "successful"
124136 // response will return a "[GameScore]" type.
125137 if let error: ParseHookResponse < [ GameScore ] > = checkHeaders ( req) {
@@ -144,9 +156,13 @@ func routes(_ app: Application) throws {
144156 }
145157
146158 // 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
150166 // Note that `ParseHookResponse<Bool>` means a "successful"
151167 // response will return a "Bool" type. Bool is the standard response with
152168 // a "true" response meaning everything is okay or continue.
@@ -161,8 +177,12 @@ func routes(_ app: Application) throws {
161177 }
162178
163179 // 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
166186 // Note that `ParseHookResponse<Bool>` means a "successful"
167187 // response will return a "Bool" type. Bool is the standard response with
168188 // a "true" response meaning everything is okay or continue. Sending "false"
@@ -178,8 +198,12 @@ func routes(_ app: Application) throws {
178198 }
179199
180200 // 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
183207 // Note that `ParseHookResponse<Bool>` means a "successful"
184208 // response will return a "Bool" type. Bool is the standard response with
185209 // a "true" response meaning everything is okay or continue.
@@ -194,8 +218,11 @@ func routes(_ app: Application) throws {
194218 }
195219
196220 // 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
199226 // Note that `ParseHookResponse<Bool>` means a "successful"
200227 // response will return a "Bool" type. Bool is the standard response with
201228 // a "true" response meaning everything is okay or continue.
@@ -210,9 +237,13 @@ func routes(_ app: Application) throws {
210237 }
211238
212239 // 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
216247 // Note that `ParseHookResponse<Bool>` means a "successful"
217248 // response will return a "Bool" type. Bool is the standard response with
218249 // a "true" response meaning everything is okay or continue.
@@ -227,9 +258,13 @@ func routes(_ app: Application) throws {
227258 }
228259
229260 // 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
233268 // Note that `ParseHookResponse<Bool>` means a "successful"
234269 // response will return a "Bool" type. Bool is the standard response with
235270 // a "true" response meaning everything is okay or continue.
0 commit comments