Skip to content

Commit f46e7c2

Browse files
authored
feat: Add maintenanceKey and bump dependencies (#79)
* feat: Add maintenanceKey and bump dependencies * lint * adjust liveQuery classes * use latest server version
1 parent a33295c commit f46e7c2

File tree

10 files changed

+821
-71
lines changed

10 files changed

+821
-71
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PARSE_SERVER_APPLICATION_ID=applicationId
2+
PARSE_SERVER_MAINTENANCE_KEY=maintenanceKey
23
PARSE_SERVER_PRIMARY_KEY=primaryKey
34
PARSE_SERVER_WEBHOOK_KEY=webhookKey
5+
POSTGRES_USER=postgres
46
POSTGRES_PASSWORD=postgres
57
PG_PARSE_USER=parse
68
PG_PARSE_PASSWORD=parse

Package.resolved

Lines changed: 45 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ let package = Package(
2121
dependencies: [
2222
.package(
2323
url: "https://github.com/vapor/vapor.git",
24-
.upToNextMajor(from: "4.102.1")
24+
.upToNextMajor(from: "4.113.2")
2525
),
2626
.package(
2727
url: "https://github.com/netreconlab/Parse-Swift.git",
28-
.upToNextMajor(from: "5.11.2")
28+
.upToNextMajor(from: "5.12.0")
2929
)
3030
],
3131
targets: [

Sources/ParseServerSwift/Parse.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func initializeServer(
7171
try await ParseSwift.initialize(
7272
applicationId: configuration.applicationId,
7373
primaryKey: configuration.primaryKey,
74+
maintenanceKey: configuration.maintenanceKey,
7475
serverURL: parseServerURL,
7576
// POST all queries instead of using GET.
7677
usingPostForQuery: true,

Sources/ParseServerSwift/ParseServerConfiguration.swift

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public struct ParseServerConfiguration {
1616
/// The application id for your Node.js Parse Server application.
1717
public internal(set) var applicationId: String
1818

19+
/// The maintenance key for your Node.js Parse Server application.
20+
public internal(set) var maintenanceKey: String?
21+
1922
/// The primary key for your Node.js Parse Server application.
2023
/// - note: This has been renamed from `masterKey` to reflect
2124
/// [inclusive language](https://github.com/dialpad/inclusive-language#motivation).
@@ -43,17 +46,22 @@ public struct ParseServerConfiguration {
4346
- parameter tlsConfiguration: Manages configuration of TLS for SwiftNIO programs.
4447
- throws: An error of `ParseError` type.
4548
- important: This initializer looks for environment variables that begin
46-
with **PARSE_SERVER_SWIFT** such as **PARSE_SERVER_SWIFT_APPLICATION_ID**
47-
and **PARSE_SERVER_SWIFT_PRIMARY_KEY**.
49+
with **PARSE_SERVER_SWIFT** such as **PARSE_SERVER_SWIFT_APPLICATION_ID**,
50+
**PARSE_SERVER_SWIFT_MAINTENANCE_KEY**, and **PARSE_SERVER_SWIFT_PRIMARY_KEY**.
4851
*/
49-
public init(app: Application,
50-
tlsConfiguration: TLSConfiguration? = nil) throws {
52+
public init(
53+
app: Application,
54+
tlsConfiguration: TLSConfiguration? = nil
55+
) throws {
5156
guard let applicationId = Environment.process.PARSE_SERVER_SWIFT_APPLICATION_ID,
5257
let primaryKey = Environment.process.PARSE_SERVER_SWIFT_PRIMARY_KEY else {
53-
throw ParseError(code: .otherCause,
54-
message: "Missing environment variables for applicationId or primaryKey")
58+
throw ParseError(
59+
code: .otherCause,
60+
message: "Missing environment variables for applicationId or primaryKey"
61+
)
5562
}
5663
self.applicationId = applicationId
64+
self.maintenanceKey = Environment.process.PARSE_SERVER_SWIFT_MAINTENANCE_KEY
5765
self.primaryKey = primaryKey
5866
app.http.server.configuration.hostname = Environment.process.PARSE_SERVER_SWIFT_HOST_NAME ?? "localhost"
5967
app.http.server.configuration.port = Int(Environment.process.PARSE_SERVER_SWIFT_PORT ?? 8080)
@@ -88,16 +96,20 @@ public struct ParseServerConfiguration {
8896
needs to be one server.
8997
- throws: An error of `ParseError` type.
9098
*/
91-
public init(app: Application,
92-
hostName: String = "localhost",
93-
port: Int = 8080,
94-
tlsConfiguration: TLSConfiguration? = nil,
95-
maxBodySize: ByteCount = "16kb",
96-
applicationId: String,
97-
primaryKey: String,
98-
webhookKey: String? = nil,
99-
parseServerURLString: String) throws {
99+
public init(
100+
app: Application,
101+
hostName: String = "localhost",
102+
port: Int = 8080,
103+
tlsConfiguration: TLSConfiguration? = nil,
104+
maxBodySize: ByteCount = "16kb",
105+
applicationId: String,
106+
maintenanceKey: String? = nil,
107+
primaryKey: String,
108+
webhookKey: String? = nil,
109+
parseServerURLString: String
110+
) throws {
100111
self.applicationId = applicationId
112+
self.maintenanceKey = maintenanceKey
101113
self.primaryKey = primaryKey
102114
self.webhookKey = webhookKey
103115

Tests/ParseServerSwiftTests/AppTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ final class AppTests: XCTestCase {
1616
hostName: "hostName",
1717
port: 8080,
1818
applicationId: "applicationId",
19+
maintenanceKey: "maintenanceKey",
1920
primaryKey: "primaryKey",
2021
webhookKey: hookKey,
21-
parseServerURLString: "primaryKey"
22+
parseServerURLString: "http://localhost:1337/1"
2223
)
2324
try await ParseServerSwift.initialize(
2425
configuration,
@@ -35,6 +36,7 @@ final class AppTests: XCTestCase {
3536
try await ParseSwift.initialize(
3637
applicationId: configuration.applicationId,
3738
primaryKey: configuration.primaryKey,
39+
maintenanceKey: configuration.maintenanceKey,
3840
serverURL: parseServerURL,
3941
usingPostForQuery: true,
4042
requestCachePolicy: .reloadIgnoringLocalCacheData
@@ -59,8 +61,9 @@ final class AppTests: XCTestCase {
5961
hostName: "hostName",
6062
port: 8080,
6163
applicationId: "applicationId",
64+
maintenanceKey: "maintenanceKey",
6265
primaryKey: "primaryKey",
63-
parseServerURLString: "primaryKey"
66+
parseServerURLString: "http://localhost:1337/1"
6467
)
6568
XCTAssertNoThrow(try setConfiguration(configuration))
6669
try await app.asyncShutdown()
@@ -73,8 +76,9 @@ final class AppTests: XCTestCase {
7376
hostName: "hostName",
7477
port: 8080,
7578
applicationId: "applicationId",
79+
maintenanceKey: "maintenanceKey",
7680
primaryKey: "primaryKey",
77-
parseServerURLString: "primaryKey"
81+
parseServerURLString: "http://localhost:1337/1"
7882
)
7983
XCTAssertThrowsError(try setConfiguration(configuration))
8084
try await app.asyncShutdown()

docker-compose.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ version: '3.7'
1717
x-shared_environment: &shared_environment
1818
LOG_LEVEL: ${LOG_LEVEL:-debug}
1919
PARSE_SERVER_APPLICATION_ID: ${PARSE_SERVER_APPLICATION_ID}
20+
PARSE_SERVER_MAINTENANCE_KEY: ${PARSE_SERVER_MAINTENANCE_KEY}
2021
PARSE_SERVER_PRIMARY_KEY: ${PARSE_SERVER_PRIMARY_KEY}
2122
PARSE_SERVER_READ_ONLY_PRIMARY_KEY: 367F7395-2E3A-46B1-ABA3-963A25D533C3
2223
PARSE_SERVER_WEBHOOK_KEY: ${PARSE_SERVER_WEBHOOK_KEY}
@@ -30,14 +31,17 @@ x-shared_environment: &shared_environment
3031
PARSE_SERVER_MOUNT_GRAPHQL: 'false'
3132
PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION: 'true' # Don't allow classes to be created on the client side. You can create classes by using ParseDashboard instead
3233
PARSE_SERVER_ALLOW_CUSTOM_OBJECTID: 'true' # Required to be true for ParseCareKit
33-
PARSE_SERVER_ENABLE_SCHEMA_HOOKS: 'true' # When this is true, only need one server for PARSE_SERVER_SWIFT_URLS
34+
PARSE_SERVER_ENABLE_SCHEMA_HOOKS: 'true' # When this is true, only need one server for PARSE_SERVER_SWIFT_URLS
35+
PARSE_SERVER_ENCODE_PARSE_OBJECT_IN_CLOUD_FUNCTION: 'true'
36+
PARSE_SERVER_PAGES_ENABLE_ROUTER": 'true'
3437
PARSE_SERVER_DIRECT_ACCESS: 'false' # WARNING: Setting to 'true' is known to cause crashes on parse-hipaa running postgres
3538
PARSE_SERVER_ENABLE_PRIVATE_USERS: 'true'
3639
PARSE_SERVER_USING_PARSECAREKIT: 'false' # If you are not using ParseCareKit, set this to 'false'
37-
PARSE_SERVER_RATE_LIMIT: 'true'
40+
PARSE_SERVER_RATE_LIMIT: 'false'
3841
PARSE_SERVER_RATE_LIMIT_REQUEST_COUNT: '100'
3942
PARSE_SERVER_RATE_LIMIT_INCLUDE_PRIMARY_KEY: 'false'
4043
PARSE_SERVER_RATE_LIMIT_INCLUDE_INTERNAL_REQUESTS: 'false'
44+
PARSE_SERVER_LIVEQUERY_CLASSNAMES: 'GameScore'
4145
PARSE_DASHBOARD_START: 'true'
4246
PARSE_DASHBOARD_APP_NAME: Parse HIPAA
4347
PARSE_DASHBOARD_USERNAMES: parse, parseRead
@@ -47,6 +51,7 @@ x-shared_environment: &shared_environment
4751
PARSE_DASHBOARD_COOKIE_SESSION_SECRET: AB8849B6-D725-4A75-AA73-AB7103F0363F # This should be constant across all deployments on your system
4852
PARSE_DASHBOARD_MOUNT_PATH: /dashboard # This needs to be exactly what you plan it to be behind the proxy, i.e. If you want to access cs.uky.edu/dashboard it should be "/dashboard"
4953
PARSE_VERBOSE: 'false'
54+
POSTGRES_USER: ${POSTGRES_USER}
5055
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Needed for wait-for-postgres.sh
5156

5257
services:
@@ -61,6 +66,7 @@ services:
6166
PARSE_SERVER_SWIFT_DEFAULT_MAX_BODY_SIZE: 16kb
6267
PARSE_SERVER_SWIFT_URLS: http://parse:1337/parse #,http://parse2:1337/parse # Only need to list one server.
6368
PARSE_SERVER_SWIFT_APPLICATION_ID: ${PARSE_SERVER_APPLICATION_ID}
69+
PARSE_SERVER_SWIFT_MAINTENANCE_KEY: ${PARSE_SERVER_MAINTENANCE_KEY}
6470
PARSE_SERVER_SWIFT_PRIMARY_KEY: ${PARSE_SERVER_PRIMARY_KEY}
6571
PARSE_SERVER_SWIFT_WEBHOOK_KEY: ${PARSE_SERVER_WEBHOOK_KEY}
6672
# ports:
@@ -74,9 +80,7 @@ services:
7480
depends_on:
7581
- parse
7682
parse:
77-
image: netreconlab/parse-hipaa:6.4.0-dashboard
78-
# Uncomment the image below to use Parse Server 5.4.0 instead. Be sure to comment out 6.0.0x
79-
#image: netreconlab/parse-hipaa:5.4.0-dashboard
83+
image: netreconlab/parse-hipaa:8.0.1-dashboard
8084
environment:
8185
<<: *shared_environment
8286
PARSE_SERVER_URL: http://parse:${PORT}${MOUNT_PATH}
@@ -87,8 +91,6 @@ services:
8791
volumes:
8892
- ./parse/wait-for-postgres.sh:/parse-server/wait-for-postgres.sh
8993
- ./parse/index.js:/parse-server/index.js
90-
# Uncomment the mount below to use Parse Server 5.4.0 instead. Be sure to comment out the index.js mount above
91-
#- ./parse/index-5.4.0.js:/parse-server/index.js
9294
- ./parse/cloud:/parse-server/cloud
9395
- ./parse/files:/parse-server/files # All files uploaded from users are stored to an ecrypted drive locally for HIPAA compliance
9496
restart: always

0 commit comments

Comments
 (0)