Skip to content

Context not showing and invalid types #170

Open

Description

@cbs-l

When trying to use the documentation example for passing in a context I am seeing that a type error is being thrown:

S2554: Expected 0 arguments, but got 1

From what I can see the method call is:

export const createAPIGatewayProxyEventV2RequestHandler = <
  Event extends APIGatewayProxyEventV2 = APIGatewayProxyEventV2,
>() => {

So looks as if it does not allow a context value? This also means that when trying to use the context value in a resolver that it is not there.

image

Activity

  1. ssshar-014 commented on Oct 17, 2024

    @ssshar-014

    @cbs-l Encountering the same issue. Any workaround for this ?

  2. ssshar-014 commented on Oct 17, 2024

    @ssshar-014

    The syntax in the documentation appears to be incorrect. Below is the corrected version that works as expected:

    export default startServerAndCreateLambdaHandler(
      server,
      handlers.createAPIGatewayProxyEventV2RequestHandler(),
      {
        context: async ({ event }) => {
          // Do some parsing on the event (parse JWT, cookie, auth header, etc.)
          return {
            isAuthenticated: true,
          };
        },
      }
    );
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions