Skip to content

v3.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 25 Jul 15:43
· 52 commits to main since this release
0450f9e

Major Changes

Minor Changes

  • #91 71c94df Thanks @BlenderDude! - ## Short circuit middleware execution

    You can now opt to return a Lambda result object directly from the middleware. This will cancel the middleware chain, bypass GraphQL request processing, and immediately return the Lambda result.

    Example

    export const handler = startServerAndCreateLambdaHandler(
      server,
      handlers.createAPIGatewayProxyEventV2RequestHandler(),
      {
        context: async () => {
          return {};
        },
        middleware: [
          async (event) => {
            const psk = Buffer.from('SuperSecretPSK');
            const token = Buffer.from(event.headers['X-Auth-Token']);
            if (
              psk.byteLength !== token.byteLength ||
              crypto.timingSafeEqual(psk, token)
            ) {
              return {
                statusCode: '403',
                body: 'Forbidden',
              };
            }
          },
        ],
      },
    );