cumulous / backend

Serverless backend for the Cumulous framework
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

presignup handler #1

Open saneera opened 6 years ago

saneera commented 6 years ago

Hi I m going to integrate only pre sign up handler and I m new to node and typescript

export const preSignUp = (newUser: SignUpUserEvent, context: any, callback: Callback) 
 and I got following error 
 Promise.resolve()
    .then(() => {  this line  what would be the cause

ERROR in ./pre-signup-lambda-integration/pre-signup-integration-request-function.ts
(12,11): error TS2345: Argument of type '() => Promise<PromiseResult<AdminLinkProviderForUserResponse, AWSError>> | undefined' is not assignable to parameter of type '((value: void) =>
PromiseResult<AdminLinkProviderForUserResponse, AWSError> | PromiseLike<Promise...'.
  Type '() => Promise<PromiseResult<AdminLinkProviderForUserResponse, AWSError>> | undefined' is not assignable to type '(value: void) => PromiseResult<AdminLinkProviderForUserResponse,
 AWSError> | PromiseLike<PromiseR...'.
    Type 'Promise<PromiseResult<AdminLinkProviderForUserResponse, AWSError>> | undefined' is not assignable to type 'PromiseResult<AdminLinkProviderForUserResponse, AWSError> | PromiseL
ike<PromiseResult<AdminLinkPr...'.
      Type 'undefined' is not assignable to type 'PromiseResult<AdminLinkProviderForUserResponse, AWSError> | PromiseLike<PromiseResult<AdminLinkPr...'.

  Error --------------------------------------------------
dinvlad commented 6 years ago

Could you provide a link to your code? Thanks

dinvlad commented 6 years ago

Sorry, I need more context. Could you link to a repo?

saneera commented 6 years ago

https://github.com/saneera/presignup/tree/master/serverless/presignup

dinvlad commented 6 years ago

I think it has to do with your custom use of types in the lambda function. E.g., you import Callback from aws-lambda, whereas I use

export type Callback = (err?: Error | string, data?: any) => void;

Perhaps try to reuse the same types first, and then see where it fails if you'd like to start using alternative types.

saneera commented 6 years ago

I tried but still fails

dinvlad commented 6 years ago

I think it has to do strict type checking in your tsconfig.json, which prevents undefined and null from being used interchangeably. I did plan to update the code to be strict at some point, but not sure I have time for that now, unfortunately. I'd recommend either disabling strict type checking, or tracing down the errors where the output of one of the helper functions can be undefined. The error seems to be in this line https://github.com/saneera/presignup/blob/b287636401c492963e5ee0624bb9f07bdc8ad4ca/serverless/presignup/my_modules/pre-signup-lambda-integration/pre-signup-integration-request-function.ts#L24

saneera commented 6 years ago

Thanks very much I did the change working fine it created two users google and native user with same sub first time not logged in second time its working fine its that normal ?

Thanks for your help again

dinvlad commented 6 years ago

Glad to hear it! I started experiencing the same problem ~ a month after writing that code. It appears to be an issue with AWS Cognito Auth service that's not yet resolved: https://forums.aws.amazon.com/thread.jspa?messageID=814706