Skip to content

Commit

Permalink
feat: add support for additional frameworks other than Express
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-vendia committed Feb 1, 2021
1 parent 7c4aa4c commit 16628b3
Show file tree
Hide file tree
Showing 105 changed files with 993 additions and 941 deletions.
11 changes: 5 additions & 6 deletions __tests__/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const eventSources = require('../src/event-sources')
const makeResolver = require('../src/make-resolver')
const ServerlessRequest = require('../src/request')
const ServerlessResponse = require('../src/response')
const expressFramework = require('../src/frameworks/express')
const { log, MockContext } = require('../jest-helpers')

const apiGatewayEventSource = eventSources.getEventSource({ eventSourceName: 'AWS_API_GATEWAY_V1' })
Expand Down Expand Up @@ -65,7 +64,7 @@ test('getPathWithQueryStringParams: array param', () => {
expect(pathWithQueryStringParams).toEqual('/foo/bar?bizz=bazz&bizz=buzz')
})

function getRequestResponse (multiValueHeaders = {}) {
function getReqRes (multiValueHeaders = {}) {
const event = {
path: '/foo',
httpMethod: 'GET',
Expand All @@ -78,13 +77,13 @@ function getRequestResponse (multiValueHeaders = {}) {
}
}
const requestValues = apiGatewayEventSource.getRequest({ event })
const requestResponse = expressFramework.getRequestResponse(requestValues)
const requestResponse = serverlessExpressTransport.getRequestResponse(requestValues)

return requestResponse
}

test('getRequestResponse: with headers', async (done) => {
const { request } = await getRequestResponse({ 'x-foo': ['foo'] })
const { request } = await getReqRes({ 'x-foo': ['foo'] })
expect(request).toBeInstanceOf(ServerlessRequest)
expect(request.body).toBeInstanceOf(Buffer)
expect(request.body.toString('utf-8')).toEqual('Hello serverless!')
Expand All @@ -99,7 +98,7 @@ test('getRequestResponse: with headers', async (done) => {
})

test('getRequestResponse: without headers', async (done) => {
const requestResponse = await getRequestResponse()
const requestResponse = await getReqRes()
expect(requestResponse.request).toBeInstanceOf(ServerlessRequest)
expect(requestResponse.request.body).toBeInstanceOf(Buffer)
expect(requestResponse.request.body.toString('utf-8')).toEqual('Hello serverless!')
Expand Down Expand Up @@ -174,7 +173,7 @@ describe.skip('forwardResponse: content-type encoding', () => {
test('content-type header missing', async (done) => {
const binaryMimeTypes = []
const multiValueHeaders = { foo: ['bar'] }
const { requestResponse } = await getRequestResponse(multiValueHeaders)
const { requestResponse } = await getReqRes(multiValueHeaders)
const response = new ServerlessResponse(requestResponse.request)
return new Promise(
(resolve) => {
Expand Down
9 changes: 3 additions & 6 deletions examples/alb/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/alb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@vendia/serverless-express": "^4.0.0-rc.5",
"@vendia/serverless-express": "^4.0.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
Expand All @@ -22,4 +22,4 @@
"devDependencies": {
"lodash": "^4.17.20"
}
}
}
71 changes: 24 additions & 47 deletions examples/basic-starter-api-gateway-v1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/basic-starter-api-gateway-v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@vendia/serverless-express": "^4.0.0-rc.8",
"@vendia/serverless-express": "^4.0.0",
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.3",
Expand All @@ -36,7 +36,7 @@
"copy-webpack-plugin": "^7.0.0",
"cross-var": "^1.1.0",
"source-map-support": "^0.5.19",
"webpack": "^5.11.1",
"webpack": "^5.19.0",
"webpack-cli": "^4.3.1"
}
}
39 changes: 18 additions & 21 deletions examples/basic-starter-api-gateway-v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/basic-starter-api-gateway-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@vendia/serverless-express": "^4.0.0-rc.10",
"@vendia/serverless-express": "^4.0.0",
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.3",
Expand All @@ -36,7 +36,7 @@
"copy-webpack-plugin": "^7.0.0",
"cross-var": "^1.1.0",
"source-map-support": "^0.5.19",
"webpack": "^5.11.1",
"webpack": "^5.19.0",
"webpack-cli": "^4.3.1"
}
}
Loading

0 comments on commit 16628b3

Please sign in to comment.