The documentation for the AWS Cognito Pre Token Generation function has node example code, but no typescript example code.
Are there typescript types I can import to strongly type the three parameters passed to the handler function?
import { TypeA, TypeB, TypeC } from '???'; // Are these defined by AWS somewhere?
exports.handler = (event: TypeA, context: TypeB, callback: TypeC) => {
event.response = {
// the good stuff goes here
}
callback(null, event)
}
2
Answers
Try this:
@types/aws-lambda contains type definitions for AWS Lambda. Specifically, events of type
PreTokenGenerationTriggerEvent
frompre-token-generation.d.ts
Also, you can use an
async
function instead of a callback.