Skip to content

Commit ad47810

Browse files
authored
Merge pull request #1160 from sharifhh/patch-1
Do not throw error if event is not http (http-cors)
2 parents 432855f + c72d287 commit ad47810

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

packages/http-cors/__tests__/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,15 +819,11 @@ test('it should set Vary header if present in config', async (t) => {
819819
})
820820
})
821821

822-
test('it should throw when not a http event', async (t) => {
822+
test('it should not throw when not a http event', async (t) => {
823823
const handler = middy((event, context) => {})
824824

825825
handler.use(cors())
826826

827827
const event = {}
828-
try {
829-
await handler(event, context)
830-
} catch (e) {
831-
t.is(e.message, 'Unknown http event format')
832-
}
828+
t.notThrows(async () => await handler(event, context))
833829
})

packages/http-cors/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ const modifyHeaders = (headers, options, request) => {
131131
const httpMethod = getVersionHttpMethod[request.event.version ?? '1.0']?.(
132132
request.event
133133
)
134-
if (!httpMethod) {
135-
throw new Error('Unknown http event format', {
136-
cause: { package: '@middy/http-cors' }
137-
})
138-
}
139134
if (
140135
httpMethod === 'OPTIONS' &&
141136
options.cacheControl &&

0 commit comments

Comments
 (0)