Add the dependency BreezeLambdaDynamoDBAPI
to a package:
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "BreezeItemAPI",
platforms: [
.macOS(.v13),
],
products: [
.executable(name: "ItemAPI", targets: ["ItemAPI"]),
],
dependencies: [
.package(url: "https://github.com/swift-sprinter/BreezeLambdaDynamoDBAPI.git", from: "0.4.0")
],
targets: [
.executableTarget(
name: "ItemAPI",
dependencies: [
.product(name: "BreezeLambdaAPI", package: "Breeze"),
.product(name: "BreezeDynamoDBService", package: "Breeze"),
]
)
]
)
Add a Codable
struct
entity conformed to the BreezeCodable
protocol:
import Foundation
import BreezeLambdaAPI
import BreezeDynamoDBService
struct Item: Codable {
public var key: String
public let name: String
public let description: String
public var createdAt: String?
public var updatedAt: String?
enum CodingKeys: String, CodingKey {
case key = "itemKey"
case name
case description
case createdAt
case updatedAt
}
}
extension Item: BreezeCodable { }
Add the implementation of the Lambda to the file swift.main
BreezeLambdaAPI<Item>.main()
Refer to the main project https://github.com/swift-serverless/Breeze for more info and working examples.
Contributions are welcome! If you encounter any issues or have ideas for improvements, please open an issue or submit a pull request.