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
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)