getCurrentInvoke
@h4ad/serverless-adapter > getCurrentInvoke
(function) getCurrentInvoke
Get the event created by the serverless trigger and the context created by the serverless environment for the current async invocation scope.
Signature:
export declare function getCurrentInvoke<TEvent = any, TContext = any>(): CurrentInvoke<TEvent, TContext>;
Returns:
CurrentInvoke <TEvent, TContext>
Remarks
This function is request-scoped. During framework execution it returns the event and context for the invocation being processed by the current async call chain. Outside a handler-created invocation scope it returns \{ event: null, context: null } .
Concurrent invocations are isolated from each other, so overlapping requests do not overwrite the current invoke visible to framework code.
Example
import type \{ ALBEvent, Context } from 'aws-lambda';
// inside framework code that handles the aws alb request.
const \{ event, context } = getCurrentInvoke<ALBEvent, Context>();