Skip to content

Commit bf35265

Browse files
authored
Merge pull request #21 from DavidWells/claude/issue-20-20250830-1624
🤖 Claude Code: Update all examples to modern runtime and ESM
2 parents 78d3120 + 5e7479b commit bf35265

File tree

143 files changed

+835
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+835
-636
lines changed

_instructor/core-concepts/1-http-hello-world/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This lesson will walk through creating a basic function triggered by a http GET
55
<!-- AUTO-GENERATED-CONTENT:START (TOC) -->
66
- [Lesson Steps](#lesson-steps)
77
- [Complete code](#complete-code)
8+
- [Additional Resources](#additional-resources)
89
<!-- AUTO-GENERATED-CONTENT:END -->
910

1011
## Lesson Steps
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
module.exports.hello = (event, context, callback) => {
2+
export const hello = (event, context) => {
33
// WORKSHOP_START
44
/* Step 1. In this_file, Create a `200` response code and return the `event` data in the response body.
55
@@ -8,7 +8,7 @@ module.exports.hello = (event, context, callback) => {
88
For more details, see the http event docs link http://bit.ly/2mkgV4P
99
*/
1010
const response = {}
11-
return callback(null, response);
11+
return response;
1212
// WORKSHOP_END
1313
// FINAL_START
1414
const response = {
@@ -19,7 +19,6 @@ module.exports.hello = (event, context, callback) => {
1919
event: event,
2020
}),
2121
}
22-
/** callback(error, response) */
23-
return callback(null, response)
22+
return response
2423
// FINAL_END
2524
}

_instructor/core-concepts/1-http-hello-world/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ service: my-first-service
33

44
provider:
55
name: aws
6-
runtime: nodejs12.x
6+
runtime: nodejs22.x
77

88
functions:
99
hello:

_instructor/core-concepts/2-http-dynamic-content/handler.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
77
Finally remember to set the headers of the response as `'Content-Type': 'text/html'` to return HTML instead of the default `json`
88
*/
9-
module.exports.queryParamsExample = (event, context, callback) => {
9+
export const queryParamsExample = (event, context) => {
1010
// WORKSHOP_START
1111
const response = {
1212
statusCode: 200,
1313
body: JSON.stringify({
1414
message: 'Hi ⊂◉‿◉つ',
1515
}),
1616
}
17-
return callback(null, response)
17+
return response
1818
// WORKSHOP_END
1919
// FINAL_START
2020
let name
@@ -24,13 +24,13 @@ module.exports.queryParamsExample = (event, context, callback) => {
2424
/* generate the hello paragraph */
2525
const helloParagraph = greetPerson(name)
2626

27-
return callback(null, {
27+
return {
2828
statusCode: 200,
2929
headers: {
3030
'Content-Type': 'text/html',
3131
},
3232
body: generateHtmlPage(helloParagraph),
33-
})
33+
}
3434
// FINAL_END
3535
}
3636

@@ -42,15 +42,15 @@ module.exports.queryParamsExample = (event, context, callback) => {
4242
4343
Finally, remember to set the headers of the response as `'Content-Type': 'text/html'` to return HTML instead of the default `json`
4444
*/
45-
module.exports.pathParamsExample = (event, context, callback) => {
45+
export const pathParamsExample = (event, context) => {
4646
// WORKSHOP_START
4747
const response = {
4848
statusCode: 200,
4949
body: JSON.stringify({
5050
message: 'Hi ⊂◉‿◉つ',
5151
}),
5252
}
53-
return callback(null, response)
53+
return response
5454
// WORKSHOP_END
5555
// FINAL_START
5656
let name
@@ -61,14 +61,14 @@ module.exports.pathParamsExample = (event, context, callback) => {
6161
/* generate the hello paragraph */
6262
const helloParagraph = greetPerson(name)
6363

64-
// callback is sending HTML back
65-
return callback(null, {
64+
// return is sending HTML back
65+
return {
6666
statusCode: 200,
6767
headers: {
6868
'Content-Type': 'text/html',
6969
},
7070
body: generateHtmlPage(helloParagraph),
71-
})
71+
}
7272
// FINAL_END
7373
}
7474

_instructor/core-concepts/2-http-dynamic-content/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ service: using-dynamic-value
33

44
provider:
55
name: aws
6-
runtime: nodejs12.x
6+
runtime: nodejs22.x
77

88
functions:
99
queryParamsExample:

_instructor/core-concepts/3-http-post-with-cors/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This lesson will walk through creating an http function triggered by a `POST` re
1313
<!-- AUTO-GENERATED-CONTENT:START (TOC) -->
1414
- [Lesson Steps](#lesson-steps)
1515
- [Complete code](#complete-code)
16+
- [Locking down cors to a specific domain](#locking-down-cors-to-a-specific-domain)
1617
<!-- AUTO-GENERATED-CONTENT:END -->
1718

1819
## Lesson Steps

_instructor/core-concepts/3-http-post-with-cors/handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
For additional information, see the cors docs http://bit.ly/2FlFSWB
77
*/
88
// WORKSHOP_END
9-
module.exports.functionWithCors = (event, context, callback) => {
9+
export const functionWithCors = (event, context) => {
1010
const response = {
1111
statusCode: 200,
1212
// FINAL_START
@@ -22,5 +22,5 @@ module.exports.functionWithCors = (event, context, callback) => {
2222
event: event,
2323
}),
2424
}
25-
return callback(null, response)
25+
return response
2626
}

_instructor/core-concepts/3-http-post-with-cors/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ service: using-http-cors-example
33

44
provider:
55
name: aws
6-
runtime: nodejs12.x
6+
runtime: nodejs22.x
77

88
functions:
99
hello:

_instructor/core-concepts/4-using-env-vars/handler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Return the environment variable in the `foo` function response
99
*/
1010
// WORKSHOP_END
11-
module.exports.foo = (event, context, callback) => {
11+
export const foo = (event, context) => {
1212
// FINAL_START
1313
console.log('process.env.MY_ENV_VAR', process.env.MY_ENV_VAR)
1414
/* MY_ENV_VAR_FOR_BAR will be undefined */
@@ -31,7 +31,7 @@ module.exports.foo = (event, context, callback) => {
3131
// FINAL_END
3232
}),
3333
}
34-
return callback(null, response)
34+
return response
3535
}
3636

3737
// WORKSHOP_START
@@ -42,7 +42,7 @@ module.exports.foo = (event, context, callback) => {
4242
Return the environment variable in the `bar` function response
4343
*/
4444
// WORKSHOP_END
45-
module.exports.bar = (event, context, callback) => {
45+
export const bar = (event, context) => {
4646
// FINAL_START
4747
/* both env variables will be accessible in bar */
4848
console.log('process.env.MY_ENV_VAR', process.env.MY_ENV_VAR)
@@ -66,5 +66,5 @@ module.exports.bar = (event, context, callback) => {
6666
// FINAL_END
6767
}),
6868
}
69-
return callback(null, response)
69+
return response
7070
}

_instructor/core-concepts/4-using-env-vars/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ service: using-env-variables-example
66
# WORKSHOP_END
77
provider:
88
name: aws
9-
runtime: nodejs12.x
9+
runtime: nodejs22.x
1010
# FINAL_START
1111
environment:
1212
MY_ENV_VAR: 'hello there'

0 commit comments

Comments
 (0)