From d10442390e8d3747b0418f7799e7738722a9fd75 Mon Sep 17 00:00:00 2001 From: gregfenton Date: Wed, 9 Aug 2023 14:25:53 -0400 Subject: [PATCH 1/3] Update create-a-dynamodb-table-in-sst.md Make a TS file not a JS file or TS/VSCode doesn't find the export. --- _chapters/create-a-dynamodb-table-in-sst.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_chapters/create-a-dynamodb-table-in-sst.md b/_chapters/create-a-dynamodb-table-in-sst.md index 3a6df31c5..518e9f03f 100644 --- a/_chapters/create-a-dynamodb-table-in-sst.md +++ b/_chapters/create-a-dynamodb-table-in-sst.md @@ -13,7 +13,7 @@ We are now going to start creating our infrastructure in [SST]({{ site.sst_githu ### Create a Stack -{%change%} Add the following to a new file in `stacks/StorageStack.js`. +{%change%} Add the following to a new file in `stacks/StorageStack.ts`. ```js import { Table } from "sst/constructs"; From 79e260402152af74a0e3de8ae63cf48d20cf0a1f Mon Sep 17 00:00:00 2001 From: Greg Fenton Date: Wed, 9 Aug 2023 14:40:10 -0400 Subject: [PATCH 2/3] Merge commit 'a4fe386d67e34f22a18ccc33e019cd6541ad8849' --- _chapters/create-a-dynamodb-table-in-sst.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_chapters/create-a-dynamodb-table-in-sst.md b/_chapters/create-a-dynamodb-table-in-sst.md index 518e9f03f..eb7eaac81 100644 --- a/_chapters/create-a-dynamodb-table-in-sst.md +++ b/_chapters/create-a-dynamodb-table-in-sst.md @@ -81,7 +81,7 @@ This will take a minute to run. {%change%} Also remove the template files. ```bash -$ rm stacks/MyStack.ts packages/core/src/time.ts packages/functions/src/lambda.ts +$ rm stacks/MyStack.ts packages/functions/src/lambda.ts ``` ### Add to the App From 28a07adb45900338fbb95fc02c68b28e25d40971 Mon Sep 17 00:00:00 2001 From: Greg Fenton Date: Wed, 9 Aug 2023 21:14:36 -0400 Subject: [PATCH 3/3] Merge commit 'b3d6c7706e331a160d2baeaad98f075f40ae9a7c' --- _chapters/add-an-api-to-create-a-note.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/_chapters/add-an-api-to-create-a-note.md b/_chapters/add-an-api-to-create-a-note.md index fef67ae85..ca6ef8c56 100644 --- a/_chapters/add-an-api-to-create-a-note.md +++ b/_chapters/add-an-api-to-create-a-note.md @@ -14,7 +14,7 @@ We'll first add an API to create a note. This API will take the note object as t ### Creating a Stack -{%change%} Create a new file in `stacks/ApiStack.js` and add the following. +{%change%} Create a new file in `stacks/ApiStack.ts` and add the following. ```js import { Api, use } from "sst/constructs"; @@ -83,7 +83,7 @@ stacks(app) { Now let's add the function that'll be creating our note. -{%change%} Create a new file in `packages/functions/src/create.js` with the following. +{%change%} Create a new file in `packages/functions/src/create.ts` with the following. ```js import * as uuid from "uuid"; @@ -194,7 +194,7 @@ Make a note of the `noteId`. We are going to use this newly created note in the Before we move on to the next chapter, let's quickly refactor the code since we are going to be doing much of the same for all of our APIs. -{%change%} Start by replacing our `create.js` with the following. +{%change%} Start by replacing our `create.ts` with the following. ```js import { Table } from "sst/node/table"; @@ -231,7 +231,7 @@ This code doesn't work just yet but it shows you what we want to accomplish: Let's start by creating a `dynamodb` util that we can share across all our functions. We'll place this in the `packages/core` directory. This is where we'll be putting all our business logic. -{%change%} Create a `packages/core/src/dynamodb.js` file with: +{%change%} Create a `packages/core/src/dynamodb.ts` file with: ```js import AWS from "aws-sdk"; @@ -249,7 +249,7 @@ export default { Here we are creating a convenience object that exposes the DynamoDB client methods that we are going to need in this guide. -{%change%} Also create a `packages/core/src/handler.js` file with the following. +{%change%} Also create a `packages/core/src/handler.ts` file with the following. ```js export default function handler(lambda) { @@ -283,7 +283,7 @@ Let's go over this in detail. - On success, we `JSON.stringify` the result and return it with a `200` status code. - If there is an error then we return the error message with a `500` status code. -It's **important to note** that the `handler.js` needs to be **imported before we import anything else**. This is because we'll be adding some error handling to it later that needs to be initialized when our Lambda function is first invoked. +It's **important to note** that the `handler.ts` needs to be **imported before we import anything else**. This is because we'll be adding some error handling to it later that needs to be initialized when our Lambda function is first invoked. Next, we are going to add the API to get a note given its id. @@ -293,7 +293,7 @@ Next, we are going to add the API to get a note given its id. - Response `statusCode: 500` - If you see a `statusCode: 500` response when you invoke your function, the error has been reported by our code in the `catch` block. You'll see a `console.error` is included in our `handler.js` code above. Incorporating logs like these can help give you insight on issues and how to resolve them. + If you see a `statusCode: 500` response when you invoke your function, the error has been reported by our code in the `catch` block. You'll see a `console.error` is included in our `handler.ts` code above. Incorporating logs like these can help give you insight on issues and how to resolve them. ```js } catch (e) {