Skip to content

Commit 53df57f

Browse files
author
Andrea Scuderi
committed
Fix Readme and rename Demo App
1 parent 07c6e38 commit 53df57f

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import PackageDescription
44

55
#if os(macOS)
6-
let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15), .iOS(.v13)]
6+
let platforms: [PackageDescription.SupportedPlatform]? = [.macOS(.v15)]
77
#else
88
let platforms: [PackageDescription.SupportedPlatform]? = nil
99
#endif
@@ -21,8 +21,8 @@ let package = Package(
2121
targets: ["BreezeLambdaAPI"]
2222
),
2323
.executable(
24-
name: "BreezeDemoApplication",
25-
targets: ["BreezeDemoApplication"]
24+
name: "BreezeLambdaItemAPI",
25+
targets: ["BreezeLambdaItemAPI"]
2626
)
2727
],
2828
dependencies: [
@@ -35,7 +35,7 @@ let package = Package(
3535
],
3636
targets: [
3737
.executableTarget(
38-
name: "BreezeDemoApplication",
38+
name: "BreezeLambdaItemAPI",
3939
dependencies: [
4040
"BreezeLambdaAPI"
4141
]

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,16 @@ extension Item: BreezeCodable { }
6969
Add the implementation of the Lambda to the file `swift.main`
7070

7171
```swift
72-
BreezeLambdaAPI<Item>.main()
72+
@main
73+
struct BreezeLambdaItemAPI {
74+
static func main() async throws {
75+
do {
76+
try await BreezeLambdaAPI<Item>().run()
77+
} catch {
78+
print(error.localizedDescription)
79+
}
80+
}
81+
}
7382
```
7483

7584
## Documentation

Sources/BreezeDemoApplication/BreezeDemoApplication.swift renamed to Sources/BreezeLambdaItemAPI/BreezeLambdaItemAPI.swift

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
import BreezeLambdaAPI
1616
import BreezeDynamoDBService
1717

18+
/// The BreezeLambdaItemAPI is an example of a Breeze Lambda API that interacts with DynamoDB to manage items.
19+
/// Use this example to understand how to create a Breeze Lambda API that can list, create, update, and delete items in a DynamoDB table.
20+
21+
/// The Item struct represents an item in the DynamoDB table.
22+
/// It conforms to Codable for easy encoding and decoding to/from JSON.
1823
struct Item: Codable {
1924
public var key: String
2025
public let name: String
@@ -31,27 +36,48 @@ struct Item: Codable {
3136
}
3237
}
3338

39+
/// BreezeCodable is a protocol that allows the Item struct to be used with Breeze Lambda API.
3440
extension Item: BreezeCodable { }
3541

42+
/// APIConfiguration is a struct that conforms to APIConfiguring.
43+
/// It provides the configuration for the Breeze Lambda API, including the DynamoDB table name, key name, and endpoint.
44+
/// It also specifies the operation to be performed, which in this case is listing items.
3645
struct APIConfiguration: APIConfiguring {
3746
let dbTimeout: Int64 = 30
3847
func operation() throws -> BreezeOperation {
3948
.list
4049
}
4150

51+
/// Get the configuration for the DynamoDB service.
52+
/// It specifies the region, table name, key name, and endpoint.
53+
/// In this example, it uses a local Localstack endpoint for testing purposes.
54+
/// You can change the region, table name, key name, and endpoint as needed for your application.
55+
/// Remove the endpoint for production use.
4256
func getConfig() throws -> BreezeDynamoDBConfig {
4357
BreezeDynamoDBConfig(region: .useast1, tableName: "Breeze", keyName: "itemKey", endpoint: "http://127.0.0.1:4566")
4458
}
4559
}
4660

4761
@main
48-
struct BreezeDemoApplication {
62+
struct BreezeLambdaItemAPI {
4963
static func main() async throws {
64+
#if DEBUG
5065
do {
5166
let lambdaAPIService = try await BreezeLambdaAPI<Item>(apiConfig: APIConfiguration())
5267
try await lambdaAPIService.run()
5368
} catch {
5469
print(error.localizedDescription)
5570
}
71+
#else
72+
// In production, you can run the BreezeLambdaAPI without the API configuration.
73+
// This will use the default configuration for the BreezeDynamoDBService.
74+
// Make sure to set the environment variables for the DynamoDB service:
75+
// DYNAMODB_TABLE_NAME, DYNAMODB_KEY_NAME, and AWS_REGION.
76+
do {
77+
try await BreezeLambdaAPI<Item>().run()
78+
} catch {
79+
print(error.localizedDescription)
80+
}
81+
#endif
5682
}
5783
}

0 commit comments

Comments
 (0)