Skip to content

Commit

Permalink
Migrate guide to SST (#569)
Browse files Browse the repository at this point in the history
* Working on draft for move to SST

* Working on the backend chapters

* Editing sst versions

* Reorganizing chapters

* Updating screenshots

* Reorganizing chapters

* Editing

* Editing the Serverless Framework section

* Editing extra credit chapters

* Updating ToC in lander

* Adding comment links
  • Loading branch information
jayair authored Aug 26, 2021
1 parent 346a2b1 commit 7b62fa4
Show file tree
Hide file tree
Showing 222 changed files with 3,729 additions and 2,646 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

The [Serverless Stack Guide](https://serverless-stack.com/#guide) is a comprehensive open source tutorial for building and deploying full-stack apps using Serverless and React on AWS.

We are going to create a [note taking app](https://demo2.serverless-stack.com) from scratch using React.js, AWS Lambda, API Gateway, DynamoDB, and Cognito.
We are going to create a [note taking app](https://demo.serverless-stack.com) from scratch using React.js, AWS Lambda, API Gateway, DynamoDB, and Cognito.

![Demo App](assets/completed-app-desktop.png)

Expand Down
1 change: 1 addition & 0 deletions _chapters/add-a-billing-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Let's add a reference to our new API and Lambda function.
events:
- http:
path: billing
cors: true
method: post
authorizer: aws_iam
```
Expand Down
13 changes: 13 additions & 0 deletions _chapters/add-a-create-note-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ export async function main(event, context) {
},
};

// Set response headers to enable CORS (Cross-Origin Resource Sharing)
const headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true
};

try {
await dynamoDb.put(params).promise();

return {
statusCode: 200,
headers: headers,
body: JSON.stringify(params.Item),
};
} catch (e) {
return {
statusCode: 500,
headers: headers,
body: JSON.stringify({ error: e.message }),
};
}
Expand Down Expand Up @@ -117,6 +125,7 @@ functions:
events:
- http:
path: notes
cors: true
method: post
```
Expand Down Expand Up @@ -256,6 +265,10 @@ export default function handler(lambda) {
return {
statusCode,
body: JSON.stringify(body),
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
},
};
};
}
Expand Down
3 changes: 2 additions & 1 deletion _chapters/add-a-delete-note-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This makes a DynamoDB `delete` call with the `userId` & `noteId` key to delete t
events:
- http:
path: notes/{id}
cors: true
method: delete
```
Expand Down Expand Up @@ -83,4 +84,4 @@ And the response should look similar to this.
}
```

Now that our APIs are complete; we are almost ready to deploy them.
Now that our APIs are complete, let's deploy them next!
1 change: 1 addition & 0 deletions _chapters/add-a-get-note-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ This follows exactly the same structure as our previous `create.js` function. Th
events:
- http:
path: notes/{id}
cors: true
method: get
```
Expand Down
1 change: 1 addition & 0 deletions _chapters/add-a-list-all-the-notes-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ This is pretty much the same as our `get.js` except we use a condition to only r
events:
- http:
path: notes
cors: true
method: get
```
Expand Down
Loading

0 comments on commit 7b62fa4

Please sign in to comment.