Skip to content

Commit

Permalink
feat: add mapping for cognito custom message handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaz committed Feb 21, 2021
1 parent 3f76536 commit 318ab34
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/sls-aws/src/cognito/user-pool-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { EnvironmentConfig, Handler, SlsEnvironment, environment } from '@cabiri-io/sls-env'
import type { Context, PreSignUpTriggerEvent, PreTokenGenerationTriggerEvent } from 'aws-lambda'
import type {
Context,
CustomMessageTriggerEvent,
PreSignUpTriggerEvent,
PreTokenGenerationTriggerEvent
} from 'aws-lambda'
import { responseOrError } from '../reponse/response-or-error'

type PreSignUpHandler = Handler<PreSignUpTriggerEvent, Context, Promise<PreSignUpTriggerEvent>>
Expand All @@ -19,5 +24,12 @@ const cognitoUserPoolPreTokenGeneration = <D, C = never>(
): SlsEnvironment<PreTokenGenerationHandler, C, D> =>
environment<PreTokenGenerationHandler, C, D>(config).successHandler(responseOrError)

export type { PreSignUpHandler, PreTokenGenerationHandler }
export { cognitoUserPoolPreSignUp, cognitoUserPoolPreTokenGeneration }
type CustomMessageHandler = Handler<CustomMessageTriggerEvent, Context, Promise<CustomMessageTriggerEvent>>

const cognitoUserPoolCustomMessage = <D, C = never>(
config?: EnvironmentConfig<CustomMessageHandler>
): SlsEnvironment<CustomMessageHandler, C, D> =>
environment<CustomMessageHandler, C, D>(config).successHandler(responseOrError)

export type { PreSignUpHandler, PreTokenGenerationHandler, CustomMessageHandler }
export { cognitoUserPoolPreSignUp, cognitoUserPoolPreTokenGeneration, cognitoUserPoolCustomMessage }

0 comments on commit 318ab34

Please sign in to comment.