Skip to content

Commit aa729c8

Browse files
trivikrkaiz-io
andauthored
chore(java): update nodejs version to 20.x (#1040)
Co-authored-by: Michael Kaiser <[email protected]>
1 parent 1e8d04f commit aa729c8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

java/my-widget-service/resources/widgets.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const AWS = require('aws-sdk');
2-
const S3 = new AWS.S3();
1+
const { S3 } = require("@aws-sdk/client-s3");
2+
const s3 = new S3();
33

44
const bucketName = process.env.BUCKET;
55

@@ -12,7 +12,7 @@ exports.main = async function(event, context) {
1212
if (method === "GET") {
1313
// GET / to get the names of all widgets
1414
if (event.path === "/") {
15-
const data = await S3.listObjectsV2({ Bucket: bucketName }).promise();
15+
const data = await s3.listObjectsV2({ Bucket: bucketName });
1616
var body = {
1717
widgets: data.Contents.map(function(e) { return e.Key })
1818
};
@@ -25,8 +25,8 @@ exports.main = async function(event, context) {
2525

2626
if (widgetName) {
2727
// GET /name to get info on widget name
28-
const data = await S3.getObject({ Bucket: bucketName, Key: widgetName}).promise();
29-
var body = data.Body.toString('utf-8');
28+
const data = await s3.getObject({ Bucket: bucketName, Key: widgetName});
29+
var body = await data.Body.transformToString();
3030

3131
return {
3232
statusCode: 200,
@@ -53,12 +53,12 @@ exports.main = async function(event, context) {
5353

5454
var base64data = new Buffer(data, 'binary');
5555

56-
await S3.putObject({
56+
await s3.putObject({
5757
Bucket: bucketName,
5858
Key: widgetName,
5959
Body: base64data,
6060
ContentType: 'application/json'
61-
}).promise();
61+
});
6262

6363
return {
6464
statusCode: 200,
@@ -78,9 +78,9 @@ exports.main = async function(event, context) {
7878
};
7979
}
8080

81-
await S3.deleteObject({
81+
await s3.deleteObject({
8282
Bucket: bucketName, Key: widgetName
83-
}).promise();
83+
});
8484

8585
return {
8686
statusCode: 200,

java/my-widget-service/src/main/java/software/amazon/awscdk/examples/MyWidgetServiceStack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public MyWidgetServiceStack(final Construct scope, final String id) {
4848
.code(Code.fromAsset("resources"))
4949
.handler("widgets.main")
5050
.timeout(Duration.seconds(300))
51-
.runtime(Runtime.NODEJS_16_X)
51+
.runtime(Runtime.NODEJS_20_X)
5252
.environment(environmentVariables)
5353
.build();
5454

0 commit comments

Comments
 (0)