Skip to content

Commit

Permalink
fix: remove unsupported stageVariables
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jul 30, 2022
1 parent 7ea4892 commit 4648d39
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 54 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ custom:
serverless-offline:
httpsProtocol: 'dev-certs'
httpPort: 4000
stageVariables:
foo: 'bar'
```

Expand Down
6 changes: 0 additions & 6 deletions src/events/http/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,24 +641,18 @@ export default class HttpServer {
event = request.payload || {}
}
} else if (integration === 'AWS_PROXY') {
const stageVariables = this.#serverless.service.custom
? this.#serverless.service.custom.stageVariables
: null

const lambdaProxyIntegrationEvent =
endpoint.isHttpApi && endpoint.payload === '2.0'
? new LambdaProxyIntegrationEventV2(
request,
stage,
endpoint.routeKey,
stageVariables,
additionalRequestContext,
)
: new LambdaProxyIntegrationEvent(
request,
stage,
requestPath,
stageVariables,
endpoint.isHttpApi ? endpoint.routeKey : null,
additionalRequestContext,
)
Expand Down
14 changes: 2 additions & 12 deletions src/events/http/lambda-events/LambdaProxyIntegrationEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,12 @@ export default class LambdaProxyIntegrationEvent {

#stage = null

#stageVariables = null

constructor(
request,
stage,
path,
stageVariables,
routeKey,
additionalRequestContext,
) {
constructor(request, stage, path, routeKey, additionalRequestContext) {
this.#additionalRequestContext = additionalRequestContext || {}
this.#path = path
this.#routeKey = routeKey
this.#request = request
this.#stage = stage
this.#stageVariables = stageVariables
}

create() {
Expand Down Expand Up @@ -227,7 +217,7 @@ export default class LambdaProxyIntegrationEvent {
stage: this.#stage,
},
resource,
stageVariables: this.#stageVariables,
stageVariables: null,
}
}
}
13 changes: 2 additions & 11 deletions src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,11 @@ export default class LambdaProxyIntegrationEventV2 {

#stage = null

#stageVariables = null

constructor(
request,
stage,
routeKey,
stageVariables,
additionalRequestContext,
) {
constructor(request, stage, routeKey, additionalRequestContext) {
this.#additionalRequestContext = additionalRequestContext || {}
this.#routeKey = routeKey
this.#request = request
this.#stage = stage
this.#stageVariables = stageVariables
}

create() {
Expand Down Expand Up @@ -183,7 +174,7 @@ export default class LambdaProxyIntegrationEventV2 {
timeEpoch: requestTimeEpoch,
},
routeKey: this.#routeKey,
stageVariables: this.#stageVariables,
stageVariables: null,
version: '2.0',
}
}
Expand Down
24 changes: 0 additions & 24 deletions tests/old-unit/LambdaProxyIntegrationEvent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,29 +747,6 @@ describe('LambdaProxyIntegrationEvent', () => {
})
})

describe('with stage variables', () => {
it('should assign the value to stageVariables', () => {
const requestBuilder = new RequestBuilder('POST', '/fn1')
requestBuilder.addBody({ key: 'value' })
requestBuilder.addHeader('content-type', 'custom/test')
const request = requestBuilder.toObject()
const path = 'path'
const stageVariables = 'stageVariables'

const lambdaProxyIntegrationEvent = new LambdaProxyIntegrationEvent(
request,
stage,
path,
stageVariables,
).create()

assert.strictEqual(
lambdaProxyIntegrationEvent.stageVariables,
'stageVariables',
)
})
})

describe('with operation name', () => {
const requestBuilder = new RequestBuilder('GET', '/fn1')
const request = requestBuilder.toObject()
Expand All @@ -782,7 +759,6 @@ describe('LambdaProxyIntegrationEvent', () => {
stage,
null,
null,
null,
{ operationName: 'getFunctionOne' },
).create()
})
Expand Down

0 comments on commit 4648d39

Please sign in to comment.