-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from H4ad/fix/alb-stringify-headers
fix(alb): alb not working when header value is not string
- Loading branch information
Showing
4 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { resolve } from 'path'; | ||
import type { ALBResult } from 'aws-lambda'; | ||
import express from 'express'; | ||
import { AlbAdapter } from '../../../src/adapters/aws/index'; | ||
import { ExpressFramework } from '../../../src/frameworks/express/index'; | ||
import { DefaultHandler } from '../../../src/handlers/default/index'; | ||
import { PromiseResolver } from '../../../src/resolvers/promise/index'; | ||
import { ServerlessAdapter } from '../../../src/index'; | ||
import { createAlbEvent } from '../../adapters/aws/utils/alb-event'; | ||
|
||
describe('ALB rejecting response when uses express.static because', () => { | ||
it('returns some headers that are not string', async () => { | ||
const app = express(); | ||
|
||
app.use(express.static(resolve(__dirname))); | ||
|
||
const handler = ServerlessAdapter.new(app) | ||
.setHandler(new DefaultHandler()) | ||
.setFramework(new ExpressFramework()) | ||
.setResolver(new PromiseResolver()) | ||
.addAdapter(new AlbAdapter()) | ||
.build(); | ||
|
||
const albEvent = createAlbEvent('GET', '/robots.txt'); | ||
|
||
const response = (await handler(albEvent, {})) as ALBResult; | ||
|
||
for (const header of Object.keys(response.headers || {})) { | ||
expect(`typeof ${header}: ${typeof response.headers![header]}`).toBe( | ||
`typeof ${header}: string`, | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |