Skip to content

Commit

Permalink
refactor(aws-lambda): merge custom-context into types (#2889)
Browse files Browse the repository at this point in the history
* refactor(aws-lambda): merge custom-context into types so they are excluded from coverage

* refactor: custom-context.ts is not needed since it is hidden by reexport
  • Loading branch information
exoego authored Jun 2, 2024
1 parent 786f9e2 commit ec3648d
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 95 deletions.
8 changes: 4 additions & 4 deletions runtime_tests/lambda/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Readable } from 'stream'
import { handle, streamHandle } from '../../src/adapter/aws-lambda/handler'
import type { LambdaEvent } from '../../src/adapter/aws-lambda/handler'
import type {
ApiGatewayRequestContext,
ApiGatewayRequestContextV2,
} from '../../src/adapter/aws-lambda/custom-context'
import { handle, streamHandle } from '../../src/adapter/aws-lambda/handler'
import type { LambdaEvent } from '../../src/adapter/aws-lambda/handler'
import type { LambdaContext } from '../../src/adapter/aws-lambda/types'
LambdaContext,
} from '../../src/adapter/aws-lambda/types'
import { getCookie, setCookie } from '../../src/helper/cookie'
import { streamSSE } from '../../src/helper/streaming'
import { Hono } from '../../src/hono'
Expand Down
87 changes: 0 additions & 87 deletions src/adapter/aws-lambda/custom-context.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/adapter/aws-lambda/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import type {
ALBRequestContext,
ApiGatewayRequestContext,
ApiGatewayRequestContextV2,
} from './custom-context'
import type { Handler, LambdaContext } from './types'
Handler,
LambdaContext,
} from './types'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/aws-lambda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export type {
ApiGatewayRequestContext,
ApiGatewayRequestContextV2,
ALBRequestContext,
} from './custom-context'
export type { LambdaContext } from './types'
LambdaContext,
} from './types'
88 changes: 88 additions & 0 deletions src/adapter/aws-lambda/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,91 @@ export type Handler<TEvent = any, TResult = any> = (
context: LambdaContext,
callback: Callback<TResult>
) => void | Promise<TResult>

interface ClientCert {
clientCertPem: string
subjectDN: string
issuerDN: string
serialNumber: string
validity: {
notBefore: string
notAfter: string
}
}

interface Identity {
accessKey?: string
accountId?: string
caller?: string
cognitoAuthenticationProvider?: string
cognitoAuthenticationType?: string
cognitoIdentityId?: string
cognitoIdentityPoolId?: string
principalOrgId?: string
sourceIp: string
user?: string
userAgent: string
userArn?: string
clientCert?: ClientCert
}

export interface ApiGatewayRequestContext {
accountId: string
apiId: string
authorizer: {
claims?: unknown
scopes?: unknown
}
domainName: string
domainPrefix: string
extendedRequestId: string
httpMethod: string
identity: Identity
path: string
protocol: string
requestId: string
requestTime: string
requestTimeEpoch: number
resourceId?: string
resourcePath: string
stage: string
}

interface Authorizer {
iam?: {
accessKey: string
accountId: string
callerId: string
cognitoIdentity: null
principalOrgId: null
userArn: string
userId: string
}
}

export interface ApiGatewayRequestContextV2 {
accountId: string
apiId: string
authentication: null
authorizer: Authorizer
domainName: string
domainPrefix: string
http: {
method: string
path: string
protocol: string
sourceIp: string
userAgent: string
}
requestId: string
routeKey: string
stage: string
time: string
timeEpoch: number
}

export interface ALBRequestContext {
elb: {
targetGroupArn: string
}
}

0 comments on commit ec3648d

Please sign in to comment.