Kind: Interface
Source: src/adapter/aws-lambda/types.ts
Part of: Adapter
ClientContext defines the request-scoped context passed through the AWS Lambda adapter. It groups the platform client API, environment values, and an open-ended Custom field for application-specific context.
Properties
| Property | Type |
|---|---|
client | ClientContextClient |
Custom | any |
env | ClientContextEnv |
Diagram
mermaidgraph LR Context[ClientContext] Client[client: ClientContextClient] Env[env: ClientContextEnv] Custom[Custom: any] Context --> Client Context --> Env Context --> Custom
Usage
tsimport type { ClientContext } from "./types";
function handleRequest(context: ClientContext) {
const region = context.env.region;
context.client.log({
message: `Handling request in ${region}`,
});
const tenantId = context.Custom?.tenantId;
return {
tenantId,
region,
};
}
AI Coding Instructions
- Pass
ClientContextthrough Lambda request handling code instead of separately passingclient,env, and custom values. - Access AWS adapter APIs through
context.clientand configuration throughcontext.env. - Treat
Customas application-defined data; narrow or validate its shape before reading properties. - Keep custom context values request-scoped to avoid sharing mutable state across Lambda invocations.
How it works
ClientContext is an exported TypeScript interface that describes the clientContext value on an AWS Lambda LambdaContext. That enclosing property is optional and may be undefined. src/adapter/aws-lambda/types.ts:8-13 src/adapter/aws-lambda/types.ts:35-47
Its required members are:
client, aClientContextClientobject containing string fields forinstallationId,appTitle,appVersionName,appVersionCode, andappPackageName. src/adapter/aws-lambda/types.ts:9 src/adapter/aws-lambda/types.ts:15-21env, aClientContextEnvobject containing string fields forplatformVersion,platform,make,model, andlocale. src/adapter/aws-lambda/types.ts:12 src/adapter/aws-lambda/types.ts:23-29
It also declares an optional, capitalized Custom member with the any type. src/adapter/aws-lambda/types.ts:11
The interface declares no methods, runtime validation, thrown errors, or side effects. src/adapter/aws-lambda/types.ts:8-13 The AWS Lambda adapter passes its received LambdaContext onward as context in streamHandle and as lambdaContext in handle; neither shown path reads clientContext directly. src/adapter/aws-lambda/handler.ts:147-157 src/adapter/aws-lambda/handler.ts:252-272
Was this page helpful?