wrap(handler, handlerName) {
        _argValidator.checkFunction(handler, 'Invalid handler (arg #1)');
        _argValidator.checkString(
            handlerName,
            1,
            'Invalid handler name (arg #2)'
        );

        return (event, context, callback) => {
            Promise.try(() => {
                let alias = context.invokedFunctionArn.split(':')[7];
                if (typeof alias === 'undefined' || alias === '$LATEST') {
                    alias = DEFAULT_ALIAS;
                }
                // eslint-disable-next-line no-console
                console.log(`Setting lambda alias to: [${alias}]`);

                const logger = this._logger.getLogger(handlerName, {
                    awsRequestId: context.awsRequestId,
                });
                logger.level = process.env.LOG_LEVEL || logger.level;

                if (event.__LAMBDA_KEEP_WARM) {
                    // eslint-disable-next-line no-console
                    console.log('Keep warm request received. Skipping');
                    return;
                } else {
                    return handler(event, context, {
                        logger,
                        alias,
                    });
                }
            })
                .then((data) => {
                    // eslint-disable-next-line no-console
                    console.log('Lambda execution completed');

                    callback(null, data);
                })
                .catch((ex) => {
                    // eslint-disable-next-line no-console
                    console.error('Error processing lambda function', ex);

                    callback(ex);
                });
        };
    }
/**
     * Creates and returns a wrapper lambda handler.
     *
     * @param {HandlerWrapper.Handler} handler A function that contains the
     *        intended lambda functionality.
     * @param {String} handlerName The name of the handler. Used for logging.
     *
     * @return {HandlerWrapper.Wrapper} A function that can be used as the
     *         AWS lambda handler.
     */
Creates and returns a wrapper lambda handler.
@param {HandlerWrapper.Handler} handler A function that contains the
intended lambda functionality.
@param {String} handlerName The name of the handler. Used for logging.

@return {HandlerWrapper.Wrapper} A function that can be used as the
AWS lambda handler.
Creates and returns a wrapper lambda handler . @param { HandlerWrapper . Handler } handler A function that contains the intended lambda functionality . @param { String } handlerName The name of the handler . Used for logging . @return { HandlerWrapper . Wrapper } A function that can be used as the AWS lambda handler .
wrap(handler, handlerName) {
        _argValidator.checkFunction(handler, 'Invalid handler (arg #1)');
        _argValidator.checkString(
            handlerName,
            1,
            'Invalid handler name (arg #2)'
        );
        return (event, context, callback) => {
            Promise.try(() => {
                let alias = context.invokedFunctionArn.split(':')[7];
                if (typeof alias === 'undefined' || alias === '$LATEST') {
                    alias = DEFAULT_ALIAS;
                }
                console.log(`Setting lambda alias to: [${alias}]`);
                const logger = this._logger.getLogger(handlerName, {
                    awsRequestId: context.awsRequestId,
                });
                logger.level = process.env.LOG_LEVEL || logger.level;
                if (event.__LAMBDA_KEEP_WARM) {
                    console.log('Keep warm request received. Skipping');
                    return;
                } else {
                    return handler(event, context, {
                        logger,
                        alias,
                    });
                }
            })
                .then((data) => {
                    console.log('Lambda execution completed');
                    callback(null, data);
                })
                .catch((ex) => {
                    console.error('Error processing lambda function', ex);
                    callback(ex);
                });
        };
    }
wrap ( handler , handlerName ) { _argValidator . checkFunction ( handler , 'Invalid handler (arg #1)' ) ; _argValidator . checkString ( handlerName , 1 , 'Invalid handler name (arg #2)' ) ; return ( event , context , callback ) => { Promise . try ( ( ) => { let alias = context . invokedFunctionArn . split ( ':' ) [ 7 ] ; if ( typeof alias === 'undefined' || alias === '$LATEST' ) { alias = DEFAULT_ALIAS ; } console . log ( ` ${ alias } ` ) ; const logger = this . _logger . getLogger ( handlerName , { awsRequestId : context . awsRequestId , } ) ; logger . level = process . env . LOG_LEVEL || logger . level ; if ( event . __LAMBDA_KEEP_WARM ) { console . log ( 'Keep warm request received. Skipping' ) ; return ; } else { return handler ( event , context , { logger , alias , } ) ; } } ) . then ( ( data ) => { console . log ( 'Lambda execution completed' ) ; callback ( null , data ) ; } ) . catch ( ( ex ) => { console . error ( 'Error processing lambda function' , ex ) ; callback ( ex ) ; } ) ; } ; }
Creates and returns a wrapper lambda handler.
Creates and returns a wrapper lambda handler .
// eslint-disable-next-line no-console // eslint-disable-next-line no-console // eslint-disable-next-line no-console // eslint-disable-next-line no-console