This is a higher-order function that wraps a given Serverless entry point
handler
and verifies that each of the HTTP parameters in the list
requiredParams
is set. If any required parameters are missing, this
function will generate an appropriate error response and send that instead of
running the code in handler
. options
is a set of optional configuration
values; for now, this is just the moreInfo
field, which adds a link to
the relevant documentation for the returned error if set.
Usage:
const params = ['param1', 'param2'];
exports.handler = expectParams(params, (context, event, callback) => {
console.log('Only gets invoked if the params are provided');
callback(null, { success: true });
});
The list of required HTTP parameters.
A Serverless entry point to wrap.
Optional configuration parameters.
A Serverless entry point suitable for use as a Function's exports.handler
.
Generated using TypeDoc
Functions that operate on Serverless
event
objects.