Skip to content

Commit d56c091

Browse files
authored
feat: Support connecting to multiple Parse Servers (#12)
* update dependencies * add support for multiple servers * Remove leaf dependency * Update README.md * add new methods * Update ci.yml * Update ci.yml * increase codecov * add more tests
1 parent 3c2b464 commit d56c091

File tree

12 files changed

+1042
-139
lines changed

12 files changed

+1042
-139
lines changed

Package.resolved

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
77
"state": {
88
"branch": null,
9-
"revision": "5bee16a79922e3efcb5cea06ecd27e6f8048b56b",
10-
"version": "1.13.1"
9+
"revision": "7f05a8da46cc2a4ab43218722298b81ac7a08031",
10+
"version": "1.13.2"
1111
}
1212
},
1313
{
1414
"package": "async-kit",
1515
"repositoryURL": "https://github.com/vapor/async-kit.git",
1616
"state": {
1717
"branch": null,
18-
"revision": "929808e51fea04f01de0e911ce826ef70c4db4ea",
19-
"version": "1.15.0"
18+
"revision": "9acea4c92f51a5885c149904f0d11db4712dda80",
19+
"version": "1.16.0"
2020
}
2121
},
2222
{
@@ -60,8 +60,8 @@
6060
"repositoryURL": "https://github.com/netreconlab/Parse-Swift.git",
6161
"state": {
6262
"branch": null,
63-
"revision": "a5ba8cb16651ea189b888981e98c2606dc73573d",
64-
"version": "4.16.2"
63+
"revision": "6cca2ff16ed16137a53e6e82f5a6286f2be3cc7c",
64+
"version": "5.0.0-beta.3"
6565
}
6666
},
6767
{
@@ -114,17 +114,17 @@
114114
"repositoryURL": "https://github.com/apple/swift-crypto.git",
115115
"state": {
116116
"branch": null,
117-
"revision": "9cc89f0170308b813af05dadcd26f9a2dee47713",
118-
"version": "2.2.3"
117+
"revision": "75ec60b8b4cc0f085c3ac414f3dca5625fa3588e",
118+
"version": "2.2.4"
119119
}
120120
},
121121
{
122122
"package": "swift-log",
123123
"repositoryURL": "https://github.com/apple/swift-log.git",
124124
"state": {
125125
"branch": null,
126-
"revision": "6fe203dc33195667ce1759bf0182975e4653ba1c",
127-
"version": "1.4.4"
126+
"revision": "3e3ef75109d6801b2c44504e73f55f0dce6662c9",
127+
"version": "1.5.1"
128128
}
129129
},
130130
{
@@ -141,8 +141,8 @@
141141
"repositoryURL": "https://github.com/apple/swift-nio.git",
142142
"state": {
143143
"branch": null,
144-
"revision": "7e3b50b38e4e66f31db6cf4a784c6af148bac846",
145-
"version": "2.46.0"
144+
"revision": "4ad2c3733845abd9ee8892a323b0fa0d80f37e34",
145+
"version": "2.47.0"
146146
}
147147
},
148148
{
@@ -195,8 +195,8 @@
195195
"repositoryURL": "https://github.com/vapor/vapor.git",
196196
"state": {
197197
"branch": null,
198-
"revision": "888c8b68642c1d340b6b3e9b2b8445fb0f6148c9",
199-
"version": "4.68.0"
198+
"revision": "a7d88181e68f03d1aeb7ecb80269ab3da9e5d155",
199+
"version": "4.69.1"
200200
}
201201
},
202202
{

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ let package = Package(
1111
],
1212
dependencies: [
1313
// 💧 A server-side Swift web framework.
14-
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.68.0")),
14+
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.69.1")),
1515
.package(url: "https://github.com/vapor/leaf.git", .upToNextMajor(from: "4.2.4")),
1616
.package(url: "https://github.com/netreconlab/Parse-Swift.git",
17-
.upToNextMajor(from: "4.16.2")),
17+
.upToNextMajor(from: "5.0.0-beta.3")),
1818
],
1919
targets: [
2020
.target(
2121
name: "ParseServerSwift",
2222
dependencies: [
23-
.product(name: "Leaf", package: "leaf"),
2423
.product(name: "Vapor", package: "vapor"),
24+
.product(name: "Leaf", package: "leaf"),
2525
.product(name: "ParseSwift", package: "Parse-Swift")
2626
],
2727
swiftSettings: [

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# ParseServerSwift
22

3+
[![Documentation](http://img.shields.io/badge/read_the-docs-2196f3.svg)](https://swiftpackageindex.com/netreconlab/parse-server-swift/documentation)
4+
[![Tuturiol](http://img.shields.io/badge/read_the-tuturials-2196f3.svg)](https://netreconlab.github.io/parse-server-swift/release/tutorials/parseserverswift/)
35
[![Build Status CI](https://github.com/netreconlab/parse-server-swift/workflows/ci/badge.svg?branch=main)](https://github.com/netreconlab/parse-server-swift/actions?query=workflow%3Aci+branch%3Amain)
46
[![codecov](https://codecov.io/gh/netreconlab/parse-server-swift/branch/main/graph/badge.svg?token=RC3FLU6BGW)](https://codecov.io/gh/netreconlab/parse-server-swift)
57
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fnetreconlab%2Fparse-server-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/netreconlab/parse-server-swift)
68
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fnetreconlab%2Fparse-server-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/netreconlab/parse-server-swift)
79

10+
---
11+
812
Write Parse Cloud Code in Swift!
913

1014
What is Cloud Code? For complex apps, sometimes you just need logic that isn’t running on a mobile device. Cloud Code makes this possible.
@@ -33,7 +37,7 @@ Configure the SDK as described in the [documentation](https://netreconlab.github
3337

3438
```swift
3539
// Required: Change to your Parse Server serverURL.
36-
guard let parseServerUrl = URL(string: "http://localhost:1337/1") else {
40+
guard let parseServerURL = URL(string: "http://localhost:1337/1") else {
3741
throw ParseError(code: .unknownError,
3842
message: "Could not make Parse Server URL")
3943
}
@@ -42,7 +46,7 @@ guard let parseServerUrl = URL(string: "http://localhost:1337/1") else {
4246
ParseSwift.initialize(applicationId: "applicationId", // Required: Change to your applicationId.
4347
clientKey: "clientKey", // Required: Change to your clientKey.
4448
primaryKey: "primaryKey", // Required: Change to your primaryKey.
45-
serverURL: parseServerUrl,
49+
serverURL: parseServerURL,
4650
usingPostForQuery: true) { _, completionHandler in
4751
completionHandler(.performDefaultHandling, nil)
4852
}

Sources/ParseServerSwift/Documentation.docc/Configuring Parse Server Swift.tutorial

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
Configure the SDK as described in the [documentation](https://parseplatform.org/Parse-Swift/release/documentation/parseswift/).
3131
```swift
3232
// Required: Change to your Parse Server serverURL.
33-
guard let parseServerUrl = URL(string: "http://localhost:1337/1") else {
33+
guard let parseServerURL = URL(string: "http://localhost:1337/1") else {
3434
throw ParseError(code: .unknownError,
3535
message: "Could not make Parse Server URL")
3636
}
@@ -39,7 +39,7 @@
3939
ParseSwift.initialize(applicationId: "applicationId", // Required: Change to your applicationId.
4040
clientKey: "clientKey", // Required: Change to your clientKey.
4141
primaryKey: "primaryKey", // Required: Change to your primaryKey.
42-
serverURL: parseServerUrl,
42+
serverURL: parseServerURL,
4343
usingPostForQuery: true) { _, completionHandler in
4444
completionHandler(.performDefaultHandling, nil)
4545
}

Sources/ParseServerSwift/Extensions/Parse+Vapor.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,22 @@ import ParseSwift
1111
extension ParseHookFunctionRequest: Content {}
1212
extension ParseHookTriggerRequest: Content {}
1313
extension ParseHookResponse: Content {}
14+
extension ParseHookRequestable {
15+
/**
16+
Produce the set of options that should be used for subsequent `ParseHook` requests.
17+
- parameter request: The HTTP request of the application.
18+
- parameter parseServerURLStrings: A set of Parse Server `URL`'s
19+
to check the `URI` against. Defaults to the set of servers added during configuration.
20+
- returns: The set of options produced by the current request.
21+
- throws: An error of `ParseError` type.
22+
- note: This options method should be used in a multi Parse Server environment.
23+
In a single Parse Server environment, use options().
24+
*/
25+
public func options(_ request: Request,
26+
parseServerURLStrings: [String] = parseServerURLStrings) throws -> API.Options {
27+
var options = self.options()
28+
options.insert(.serverURL(try serverURLString(request.url,
29+
parseServerURLStrings: parseServerURLStrings)))
30+
return options
31+
}
32+
}

0 commit comments

Comments
 (0)