Skip to content

feat: Add maintenanceKey and bump dependencies #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PARSE_SERVER_APPLICATION_ID=applicationId
PARSE_SERVER_MAINTENANCE_KEY=maintenanceKey
PARSE_SERVER_PRIMARY_KEY=primaryKey
PARSE_SERVER_WEBHOOK_KEY=webhookKey
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
PG_PARSE_USER=parse
PG_PARSE_PASSWORD=parse
Expand Down
63 changes: 45 additions & 18 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/vapor/vapor.git",
.upToNextMajor(from: "4.102.1")
.upToNextMajor(from: "4.113.2")
),
.package(
url: "https://github.com/netreconlab/Parse-Swift.git",
.upToNextMajor(from: "5.11.2")
.upToNextMajor(from: "5.12.0")
)
],
targets: [
Expand Down
1 change: 1 addition & 0 deletions Sources/ParseServerSwift/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func initializeServer(
try await ParseSwift.initialize(
applicationId: configuration.applicationId,
primaryKey: configuration.primaryKey,
maintenanceKey: configuration.maintenanceKey,
serverURL: parseServerURL,
// POST all queries instead of using GET.
usingPostForQuery: true,
Expand Down
42 changes: 27 additions & 15 deletions Sources/ParseServerSwift/ParseServerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public struct ParseServerConfiguration {
/// The application id for your Node.js Parse Server application.
public internal(set) var applicationId: String

/// The maintenance key for your Node.js Parse Server application.
public internal(set) var maintenanceKey: String?

/// The primary key for your Node.js Parse Server application.
/// - note: This has been renamed from `masterKey` to reflect
/// [inclusive language](https://github.com/dialpad/inclusive-language#motivation).
Expand Down Expand Up @@ -43,17 +46,22 @@ public struct ParseServerConfiguration {
- parameter tlsConfiguration: Manages configuration of TLS for SwiftNIO programs.
- throws: An error of `ParseError` type.
- important: This initializer looks for environment variables that begin
with **PARSE_SERVER_SWIFT** such as **PARSE_SERVER_SWIFT_APPLICATION_ID**
and **PARSE_SERVER_SWIFT_PRIMARY_KEY**.
with **PARSE_SERVER_SWIFT** such as **PARSE_SERVER_SWIFT_APPLICATION_ID**,
**PARSE_SERVER_SWIFT_MAINTENANCE_KEY**, and **PARSE_SERVER_SWIFT_PRIMARY_KEY**.
*/
public init(app: Application,
tlsConfiguration: TLSConfiguration? = nil) throws {
public init(
app: Application,
tlsConfiguration: TLSConfiguration? = nil
) throws {
guard let applicationId = Environment.process.PARSE_SERVER_SWIFT_APPLICATION_ID,
let primaryKey = Environment.process.PARSE_SERVER_SWIFT_PRIMARY_KEY else {
throw ParseError(code: .otherCause,
message: "Missing environment variables for applicationId or primaryKey")
throw ParseError(
code: .otherCause,
message: "Missing environment variables for applicationId or primaryKey"
)
}
self.applicationId = applicationId
self.maintenanceKey = Environment.process.PARSE_SERVER_SWIFT_MAINTENANCE_KEY
self.primaryKey = primaryKey
app.http.server.configuration.hostname = Environment.process.PARSE_SERVER_SWIFT_HOST_NAME ?? "localhost"
app.http.server.configuration.port = Int(Environment.process.PARSE_SERVER_SWIFT_PORT ?? 8080)
Expand Down Expand Up @@ -88,16 +96,20 @@ public struct ParseServerConfiguration {
needs to be one server.
- throws: An error of `ParseError` type.
*/
public init(app: Application,
hostName: String = "localhost",
port: Int = 8080,
tlsConfiguration: TLSConfiguration? = nil,
maxBodySize: ByteCount = "16kb",
applicationId: String,
primaryKey: String,
webhookKey: String? = nil,
parseServerURLString: String) throws {
public init(
app: Application,
hostName: String = "localhost",
port: Int = 8080,
tlsConfiguration: TLSConfiguration? = nil,
maxBodySize: ByteCount = "16kb",
applicationId: String,
maintenanceKey: String? = nil,
primaryKey: String,
webhookKey: String? = nil,
parseServerURLString: String
) throws {
self.applicationId = applicationId
self.maintenanceKey = maintenanceKey
self.primaryKey = primaryKey
self.webhookKey = webhookKey

Expand Down
10 changes: 7 additions & 3 deletions Tests/ParseServerSwiftTests/AppTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ final class AppTests: XCTestCase {
hostName: "hostName",
port: 8080,
applicationId: "applicationId",
maintenanceKey: "maintenanceKey",
primaryKey: "primaryKey",
webhookKey: hookKey,
parseServerURLString: "primaryKey"
parseServerURLString: "http://localhost:1337/1"
)
try await ParseServerSwift.initialize(
configuration,
Expand All @@ -35,6 +36,7 @@ final class AppTests: XCTestCase {
try await ParseSwift.initialize(
applicationId: configuration.applicationId,
primaryKey: configuration.primaryKey,
maintenanceKey: configuration.maintenanceKey,
serverURL: parseServerURL,
usingPostForQuery: true,
requestCachePolicy: .reloadIgnoringLocalCacheData
Expand All @@ -59,8 +61,9 @@ final class AppTests: XCTestCase {
hostName: "hostName",
port: 8080,
applicationId: "applicationId",
maintenanceKey: "maintenanceKey",
primaryKey: "primaryKey",
parseServerURLString: "primaryKey"
parseServerURLString: "http://localhost:1337/1"
)
XCTAssertNoThrow(try setConfiguration(configuration))
try await app.asyncShutdown()
Expand All @@ -73,8 +76,9 @@ final class AppTests: XCTestCase {
hostName: "hostName",
port: 8080,
applicationId: "applicationId",
maintenanceKey: "maintenanceKey",
primaryKey: "primaryKey",
parseServerURLString: "primaryKey"
parseServerURLString: "http://localhost:1337/1"
)
XCTAssertThrowsError(try setConfiguration(configuration))
try await app.asyncShutdown()
Expand Down
16 changes: 9 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ version: '3.7'
x-shared_environment: &shared_environment
LOG_LEVEL: ${LOG_LEVEL:-debug}
PARSE_SERVER_APPLICATION_ID: ${PARSE_SERVER_APPLICATION_ID}
PARSE_SERVER_MAINTENANCE_KEY: ${PARSE_SERVER_MAINTENANCE_KEY}
PARSE_SERVER_PRIMARY_KEY: ${PARSE_SERVER_PRIMARY_KEY}
PARSE_SERVER_READ_ONLY_PRIMARY_KEY: 367F7395-2E3A-46B1-ABA3-963A25D533C3
PARSE_SERVER_WEBHOOK_KEY: ${PARSE_SERVER_WEBHOOK_KEY}
Expand All @@ -30,14 +31,17 @@ x-shared_environment: &shared_environment
PARSE_SERVER_MOUNT_GRAPHQL: 'false'
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
PARSE_SERVER_ALLOW_CUSTOM_OBJECTID: 'true' # Required to be true for ParseCareKit
PARSE_SERVER_ENABLE_SCHEMA_HOOKS: 'true' # When this is true, only need one server for PARSE_SERVER_SWIFT_URLS
PARSE_SERVER_ENABLE_SCHEMA_HOOKS: 'true' # When this is true, only need one server for PARSE_SERVER_SWIFT_URLS
PARSE_SERVER_ENCODE_PARSE_OBJECT_IN_CLOUD_FUNCTION: 'true'
PARSE_SERVER_PAGES_ENABLE_ROUTER": 'true'
PARSE_SERVER_DIRECT_ACCESS: 'false' # WARNING: Setting to 'true' is known to cause crashes on parse-hipaa running postgres
PARSE_SERVER_ENABLE_PRIVATE_USERS: 'true'
PARSE_SERVER_USING_PARSECAREKIT: 'false' # If you are not using ParseCareKit, set this to 'false'
PARSE_SERVER_RATE_LIMIT: 'true'
PARSE_SERVER_RATE_LIMIT: 'false'
PARSE_SERVER_RATE_LIMIT_REQUEST_COUNT: '100'
PARSE_SERVER_RATE_LIMIT_INCLUDE_PRIMARY_KEY: 'false'
PARSE_SERVER_RATE_LIMIT_INCLUDE_INTERNAL_REQUESTS: 'false'
PARSE_SERVER_LIVEQUERY_CLASSNAMES: 'GameScore'
PARSE_DASHBOARD_START: 'true'
PARSE_DASHBOARD_APP_NAME: Parse HIPAA
PARSE_DASHBOARD_USERNAMES: parse, parseRead
Expand All @@ -47,6 +51,7 @@ x-shared_environment: &shared_environment
PARSE_DASHBOARD_COOKIE_SESSION_SECRET: AB8849B6-D725-4A75-AA73-AB7103F0363F # This should be constant across all deployments on your system
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"
PARSE_VERBOSE: 'false'
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # Needed for wait-for-postgres.sh

services:
Expand All @@ -61,6 +66,7 @@ services:
PARSE_SERVER_SWIFT_DEFAULT_MAX_BODY_SIZE: 16kb
PARSE_SERVER_SWIFT_URLS: http://parse:1337/parse #,http://parse2:1337/parse # Only need to list one server.
PARSE_SERVER_SWIFT_APPLICATION_ID: ${PARSE_SERVER_APPLICATION_ID}
PARSE_SERVER_SWIFT_MAINTENANCE_KEY: ${PARSE_SERVER_MAINTENANCE_KEY}
PARSE_SERVER_SWIFT_PRIMARY_KEY: ${PARSE_SERVER_PRIMARY_KEY}
PARSE_SERVER_SWIFT_WEBHOOK_KEY: ${PARSE_SERVER_WEBHOOK_KEY}
# ports:
Expand All @@ -74,9 +80,7 @@ services:
depends_on:
- parse
parse:
image: netreconlab/parse-hipaa:6.4.0-dashboard
# Uncomment the image below to use Parse Server 5.4.0 instead. Be sure to comment out 6.0.0x
#image: netreconlab/parse-hipaa:5.4.0-dashboard
image: netreconlab/parse-hipaa:8.0.1-dashboard
environment:
<<: *shared_environment
PARSE_SERVER_URL: http://parse:${PORT}${MOUNT_PATH}
Expand All @@ -87,8 +91,6 @@ services:
volumes:
- ./parse/wait-for-postgres.sh:/parse-server/wait-for-postgres.sh
- ./parse/index.js:/parse-server/index.js
# Uncomment the mount below to use Parse Server 5.4.0 instead. Be sure to comment out the index.js mount above
#- ./parse/index-5.4.0.js:/parse-server/index.js
- ./parse/cloud:/parse-server/cloud
- ./parse/files:/parse-server/files # All files uploaded from users are stored to an ecrypted drive locally for HIPAA compliance
restart: always
Expand Down
Loading
Loading