Skip to content
Myr

fix(lambda-edge) Adding Export Type CloudFrontResponse and CloudFrontConfig (#1263)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* export type * revert

authored by watany · committed by GitHub · parent 84973c9 · Browse files · 3 files+54 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+54 added−3 removed

  • tests:+51 added−1 removed
  • other:+3 added−2 removed

3 files+54 added−3 removed

modified:runtime_tests/lambda-edge/index.test.ts+51 added-1 removed
1/* eslint-disable quotes */2import type { Callback, CloudFrontRequest, CloudFrontResponse } from '../../src/adapter/lambda-edge/handler'2import type { Callback, CloudFrontConfig, CloudFrontRequest, CloudFrontResponse } from '../../src/adapter/lambda-edge/handler'3import { handle } from '../../src/adapter/lambda-edge/handler'4import { Hono } from '../../src/hono'5import { basicAuth } from '../../src/middleware/basic-auth'67type Bindings = {8 callback: Callback9 config: CloudFrontConfig10 request: CloudFrontRequest11 response: CloudFrontResponse12}13
19 unmodified lines
33 await next()34 c.env.callback(null, c.env.request)35 })3637 app.get('/config/eventCheck', async (c, next) => {38 await next()39 if(c.env.config.eventType in ['viewer-request', 'origin-request']) {40 c.env.callback(null, c.env.request)41 } else {42 c.env.callback(null, c.env.response)43 }44 })4546 app.get('/callback/response', async (c, next) => {47 await next()48 c.env.callback(null, c.env.response)49 })
994 unmodified lines
1044 value: "Foo"1045 }1046 ]);1047 })10481049 it('Callback Event (Lambda@Edge response)', async () => {1050 const event = {1051 Records: [1052 {1053 cf: {1054 config: {1055 distributionDomainName: 'example.com',1056 distributionId: 'EDFDVBD6EXAMPLE',1057 eventType: 'viewer-response',1058 requestId: '4TyzHTaYWb1GX1qTfsHhEqV6HUDd_BzoBZnwfnvQc_1oF26ClkoUSEQ==',1059 },1060 request: {1061 clientIp: '203.0.113.178',1062 headers: {1063 host: [1064 {1065 key: 'Host',1066 value: 'example.com',1067 },1068 ],1069 },1070 method: 'GET',1071 querystring: '',1072 uri: '/config/eventCheck',1073 },1074 }1075 },1076 ],1077 }1078 1079 let called = false1080 await handler(event, {}, (_err, result) => {1081 called = true1082 })10831084 expect(called).toBe(true)1085 })108610871088})
modified:src/adapter/lambda-edge/handler.ts+2 added-1 removed
modified:src/adapter/lambda-edge/index.ts+1 added-1 removed