From 89491041985331963b7c67d99cd503d02eefdae6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:34:23 +0000 Subject: [PATCH 1/3] Initial plan From 9755fd16db705c7ed694a048a4195a51e0335787 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:38:01 +0000 Subject: [PATCH 2/3] feat: add missing typeguard exports for events and requests Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com> --- index.js | 12 ++++++++++++ lib/typeguards.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/index.js b/index.js index c8a217b..16fdc40 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,12 @@ const { isApiGatewayContext, isApiGatewayV2Context, isAlbContext, + isApiGatewayEvent, + isApiGatewayV2Event, + isAlbEvent, + isApiGatewayRequest, + isApiGatewayV2Request, + isAlbRequest, } = require('./lib/typeguards'); class API { @@ -564,3 +570,9 @@ module.exports.default = module.exports; module.exports.isApiGatewayContext = isApiGatewayContext; module.exports.isApiGatewayV2Context = isApiGatewayV2Context; module.exports.isAlbContext = isAlbContext; +module.exports.isApiGatewayEvent = isApiGatewayEvent; +module.exports.isApiGatewayV2Event = isApiGatewayV2Event; +module.exports.isAlbEvent = isAlbEvent; +module.exports.isApiGatewayRequest = isApiGatewayRequest; +module.exports.isApiGatewayV2Request = isApiGatewayV2Request; +module.exports.isAlbRequest = isAlbRequest; diff --git a/lib/typeguards.js b/lib/typeguards.js index 7188004..86a53f4 100644 --- a/lib/typeguards.js +++ b/lib/typeguards.js @@ -12,8 +12,38 @@ const isAlbContext = (context) => { return 'elb' in context; }; +const isApiGatewayEvent = (event) => { + return event.requestContext && 'identity' in event.requestContext; +}; + +const isApiGatewayV2Event = (event) => { + return event.requestContext && 'http' in event.requestContext; +}; + +const isAlbEvent = (event) => { + return event.requestContext && 'elb' in event.requestContext; +}; + +const isApiGatewayRequest = (req) => { + return req.requestContext && 'identity' in req.requestContext; +}; + +const isApiGatewayV2Request = (req) => { + return req.requestContext && 'http' in req.requestContext; +}; + +const isAlbRequest = (req) => { + return req.requestContext && 'elb' in req.requestContext; +}; + module.exports = { isApiGatewayContext, isApiGatewayV2Context, isAlbContext, + isApiGatewayEvent, + isApiGatewayV2Event, + isAlbEvent, + isApiGatewayRequest, + isApiGatewayV2Request, + isAlbRequest, }; From 784402a72c55fbc92ae44ff7391cbb9399fb4154 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 19:38:43 +0000 Subject: [PATCH 3/3] fix: add null/undefined checks to typeguards Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com> --- lib/typeguards.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/typeguards.js b/lib/typeguards.js index 86a53f4..2897df9 100644 --- a/lib/typeguards.js +++ b/lib/typeguards.js @@ -1,39 +1,39 @@ 'use strict'; const isApiGatewayContext = (context) => { - return 'identity' in context; + return context && 'identity' in context; }; const isApiGatewayV2Context = (context) => { - return 'http' in context; + return context && 'http' in context; }; const isAlbContext = (context) => { - return 'elb' in context; + return context && 'elb' in context; }; const isApiGatewayEvent = (event) => { - return event.requestContext && 'identity' in event.requestContext; + return event && event.requestContext && 'identity' in event.requestContext; }; const isApiGatewayV2Event = (event) => { - return event.requestContext && 'http' in event.requestContext; + return event && event.requestContext && 'http' in event.requestContext; }; const isAlbEvent = (event) => { - return event.requestContext && 'elb' in event.requestContext; + return event && event.requestContext && 'elb' in event.requestContext; }; const isApiGatewayRequest = (req) => { - return req.requestContext && 'identity' in req.requestContext; + return req && req.requestContext && 'identity' in req.requestContext; }; const isApiGatewayV2Request = (req) => { - return req.requestContext && 'http' in req.requestContext; + return req && req.requestContext && 'http' in req.requestContext; }; const isAlbRequest = (req) => { - return req.requestContext && 'elb' in req.requestContext; + return req && req.requestContext && 'elb' in req.requestContext; }; module.exports = {