Skip to content

Commit 7ae9640

Browse files
Update Readme.md
1 parent aaaaa37 commit 7ae9640

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,37 @@
44

55
This package demonstrates how to write a Scalable REST API with the Serverless stack by using only Swift as a development language.
66

7-
## Product API Example
7+
## Product API based on Breeze
88

9-
The example shows how to build a Rest API based on a `Product` swift class.
9+
The example shows how to build and deploy a Rest API based on a `Product` swift struct using [Breeze](https://github.com/swift-sprinter/Breeze.git)
10+
11+
The following code is all you need to implement the engine of a Serverless Rest API in Swift.
12+
The Serverless Rest API implements a CRUD interface to store the `Product` in DynamoDB.
1013

1114
```swift
12-
public struct Product: Codable {
13-
public let sku: String
15+
import Foundation
16+
import BreezeLambdaAPI
17+
import BreezeDynamoDBService
18+
19+
struct Product: Codable {
20+
public var key: String
1421
public let name: String
1522
public let description: String
1623
public var createdAt: String?
1724
public var updatedAt: String?
25+
26+
enum CodingKeys: String, CodingKey {
27+
case key = "sku"
28+
case name
29+
case description
30+
case createdAt
31+
case updatedAt
32+
}
1833
}
34+
35+
extension Product: BreezeCodable { }
36+
37+
BreezeLambdaAPI<Product>.main()
1938
```
2039
![](images/postman.png)
2140

0 commit comments

Comments
 (0)