File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
This package demonstrates how to write a Scalable REST API with the Serverless stack by using only Swift as a development language.
6
6
7
- ## Product API Example
7
+ ## Product API based on Breeze
8
8
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.
10
13
11
14
``` 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
14
21
public let name: String
15
22
public let description: String
16
23
public var createdAt: String ?
17
24
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
+ }
18
33
}
34
+
35
+ extension Product : BreezeCodable { }
36
+
37
+ BreezeLambdaAPI< Product> .main ()
19
38
```
20
39
![ ] ( images/postman.png )
21
40
You can’t perform that action at this time.
0 commit comments