Skip to content
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
4 changes: 2 additions & 2 deletions Package.resolved

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

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
),
.package(
url: "https://github.com/netreconlab/Parse-Swift.git",
.upToNextMajor(from: "5.10.0")
.upToNextMajor(from: "5.10.1")
)
],
targets: [
Expand Down
53 changes: 53 additions & 0 deletions Sources/ParseServerSwift/Extensions/Parse+Vapor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ParseSwift
extension ParseHookFunctionRequest: Content {}
extension ParseHookTriggerRequest: Content {}
extension ParseHookResponse: Content {}

public extension ParseHookRequestable {
/**
Produce the set of options that should be used for subsequent `ParseHook` requests.
Expand Down Expand Up @@ -53,3 +54,55 @@ public extension ParseHookRequestable {
return try await self.hydrateUser(options: updatedOptions)
}
}

extension ParseEncoder: ContentEncoder {

public func encode<E>(
_ encodable: E,
to body: inout ByteBuffer,
headers: inout HTTPHeaders
) throws where E: Encodable {
try self.encode(
encodable,
to: &body,
headers: &headers,
userInfo: [:]
)
}

public func encode<E>(
_ encodable: E,
to body: inout ByteBuffer,
headers: inout HTTPHeaders,
userInfo: [CodingUserInfoKey: Sendable]
) throws where E: Encodable {
headers.contentType = .json
let jsonEncoder = User.getJSONEncoder()

if !userInfo.isEmpty {
try body.writeBytes(JSONEncoder.custom(
dates: jsonEncoder.dateEncodingStrategy,
data: jsonEncoder.dataEncodingStrategy,
keys: jsonEncoder.keyEncodingStrategy,
format: jsonEncoder.outputFormatting,
floats: jsonEncoder.nonConformingFloatEncodingStrategy,
userInfo: jsonEncoder.userInfo.merging(userInfo) { $1 }
).encode(encodable))
} else {
if let parseEncodable = encodable as? ParseCloudTypeable {
try body.writeBytes(self.encode(parseEncodable, skipKeys: .cloud))
} else if let parseEncodable = encodable as? ParseEncodable {
let skipKeys: SkipKeys
if !ParseSwift.configuration.isRequiringCustomObjectIds {
skipKeys = .object
} else {
skipKeys = .customObjectId
}
try body.writeBytes(self.encode(parseEncodable, skipKeys: skipKeys))
} else {
try body.writeBytes(jsonEncoder.encode(encodable))
}

}
}
}
2 changes: 1 addition & 1 deletion Sources/ParseServerSwift/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func initializeServer(_ configuration: ParseServerConfiguration,
app: Application) async throws {

// Parse uses tailored encoders/decoders. These can be retrieved from any ParseObject
ContentConfiguration.global.use(encoder: User.getJSONEncoder(), for: .json)
ContentConfiguration.global.use(encoder: User.getEncoder(), for: .json)
ContentConfiguration.global.use(decoder: User.getDecoder(), for: .json)

guard let parseServerURL = URL(string: configuration.primaryParseServerURLString) else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseServerSwift/ParseServerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public struct ParseServerConfiguration {

var hooks = Hooks()
var isTesting = false
var logger = Logger(label: "com.parseserverswift")
var logger = Logger(label: "com.parse-server-swift")

/**
Create a configuration for `ParseServerSwift`.
Expand Down