File tree Expand file tree Collapse file tree 6 files changed +39
-3
lines changed Expand file tree Collapse file tree 6 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,8 @@ serverlessExpress({
281281 'AWS_SQS': '/sqs'
282282 'AWS_EVENTBRIDGE': '/eventbridge',
283283 'AWS_KINESIS_DATA_STREAM': '/kinesis',
284+ 'AWS_S3': '/s3',
285+ 'AWS_STEP_FUNCTIONS': '/step-functions',
284286 }
285287})
286288` ` `
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Handler } from 'aws-lambda';
33import { Logger } from './logger' ;
44import Framework from './frameworks' ;
55
6- type EventSources = 'AWS_SNS' | 'AWS_DYNAMODB' | 'AWS_EVENTBRIDGE' | 'AWS_SQS' | 'AWS_KINESIS_DATA_STREAM' | 'AWS_S3' ;
6+ type EventSources = 'AWS_SNS' | 'AWS_DYNAMODB' | 'AWS_EVENTBRIDGE' | 'AWS_SQS' | 'AWS_KINESIS_DATA_STREAM' | 'AWS_S3' | 'AWS_STEP_FUNCTIONS' ;
77
88interface EventSource {
99 getRequest ?: any ; // TODO:
Original file line number Diff line number Diff line change 1+ const getRequestValuesFromStepFunctions = ( { event } ) => {
2+ const method = 'POST'
3+ const headers = { host : 'stepfunctions.amazonaws.com' }
4+ const body = event
5+
6+ return {
7+ method,
8+ headers,
9+ body
10+ }
11+ }
12+
13+ const getResponseToStepFunctions = ( {
14+ body,
15+ isBase64Encoded = false
16+ } ) => {
17+ if ( isBase64Encoded ) {
18+ throw new Error ( 'base64 encoding is not supported' )
19+ }
20+
21+ return JSON . parse ( body )
22+ }
23+
24+ module . exports = {
25+ getRequest : getRequestValuesFromStepFunctions ,
26+ getResponse : getResponseToStepFunctions
27+ }
Original file line number Diff line number Diff line change 11const { getRequest, getResponse } = require ( './http-function-runtime-v3' )
22
33module . exports = {
4- getRequest : getRequest ,
5- getResponse : getResponse
4+ getRequest,
5+ getResponse
66}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const azureHttpFunctionV4EventSource = require('./azure/http-function-runtime-v4
1010const awsEventBridgeEventSource = require ( './aws/eventbridge' )
1111const awsKinesisEventSource = require ( './aws/kinesis' )
1212const awsS3 = require ( './aws/s3' )
13+ const awsStepFunctionsEventSource = require ( './aws/step-functions' )
1314
1415function getEventSource ( { eventSourceName } ) {
1516 switch ( eventSourceName ) {
@@ -37,6 +38,8 @@ function getEventSource ({ eventSourceName }) {
3738 return awsKinesisEventSource
3839 case 'AWS_S3' :
3940 return awsS3
41+ case 'AWS_STEP_FUNCTIONS' :
42+ return awsStepFunctionsEventSource
4043 default :
4144 throw new Error ( 'Couldn\'t detect valid event source.' )
4245 }
Original file line number Diff line number Diff line change @@ -127,6 +127,10 @@ function getEventSourceNameBasedOnEvent ({
127127 return 'AWS_EVENTBRIDGE'
128128 }
129129
130+ if ( event . context && event . context . Execution && event . context . State && event . context . StateMachine ) {
131+ return 'AWS_STEP_FUNCTIONS'
132+ }
133+
130134 throw new Error ( 'Unable to determine event source based on event.' )
131135}
132136
You can’t perform that action at this time.
0 commit comments