Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 2x 2x 31x 2x 31x | import { CloudFrontRequest, CloudFrontRequestEvent } from 'aws-lambda'
export function toAwsResponse<T>(value: T) {
return {
promise: () => Promise.resolve(value),
}
}
export const mockRequest = (
uri: string,
querystring = 'apiKey=ujKG34hUYKLJKJ1F&version=3&loaderVersion=3.6.2',
method = 'POST'
) => {
return {
clientIp: '1.1.1.1',
method: method,
uri,
querystring,
headers: {
host: [
{
key: 'host',
value: 'adewe.cloudfront.net',
},
],
cookie: [
{
key: 'cookie',
value: '',
},
],
},
origin: {
s3: {
domainName: 'adewe.cloudfront.net',
path: '/',
region: 'us',
authMethod: 'origin-access-identity',
customHeaders: {
fpjs_pre_shared_secret: [
{
key: 'fpjs_pre_shared_secret',
value: 'qwertyuio1356767',
},
],
fpjs_agent_download_path: [
{
key: 'fpjs_agent_download_path',
value: 'greiodsfkljlds',
},
],
fpjs_get_result_path: [
{
key: 'fpjs_get_result_path',
value: 'result',
},
],
},
},
},
} satisfies CloudFrontRequest
}
export const mockEvent = (request: CloudFrontRequest): CloudFrontRequestEvent => {
return {
Records: [
{
cf: {
request,
config: {
eventType: 'origin-request',
requestId: 'fake-id',
distributionId: 'fake-id',
distributionDomainName: 'fake-domain.tld',
},
},
},
],
}
}
|