Skip to content

Commit b18bbec

Browse files
authored
fix(create-twilio-function): fix hello-world template (#531)
* fix(create-twilio-function): fix hello-world template * fix(create-twilio-function): add changeset
1 parent 2bc2beb commit b18bbec

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.changeset/sour-impalas-sing.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-twilio-function': minor
3+
---
4+
5+
fix hello-world template

packages/create-twilio-function/templates/typescript/src/functions/hello-world.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,30 @@ import {
55
Context,
66
ServerlessCallback,
77
ServerlessFunctionSignature,
8+
ServerlessEventObject,
89
} from '@twilio-labs/serverless-runtime-types/types';
910

1011
type MyEvent = {
11-
Body?: string
12-
}
12+
Body?: string;
13+
};
1314

1415
// If you want to use environment variables, you will need to type them like
1516
// this and add them to the Context in the function signature as
1617
// Context<MyContext> as you see below.
1718
type MyContext = {
18-
GREETING?: string
19-
}
19+
GREETING?: string;
20+
};
2021

21-
export const handler: ServerlessFunctionSignature = function(
22+
export const handler: ServerlessFunctionSignature = function (
2223
context: Context<MyContext>,
23-
event: MyEvent,
24+
event: ServerlessEventObject<MyEvent>,
2425
callback: ServerlessCallback
2526
) {
2627
const twiml = new Twilio.twiml.VoiceResponse();
27-
twiml.say(`${context.GREETING ? context.GREETING : 'Hello'} ${event.Body ? event.Body : 'World'}!`);
28+
twiml.say(
29+
`${context.GREETING ? context.GREETING : 'Hello'} ${
30+
event.Body ? event.Body : 'World'
31+
}!`
32+
);
2833
callback(null, twiml);
29-
};
34+
};

0 commit comments

Comments
 (0)