Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

leanser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leanser

AWS Lambda Cleaner - Cleanup resources on AWS Lambda container shutdown (timeout and/or spin-down)

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

leanser

build Status npm version license

AWS Lambda Cleaner - Cleanup resources on AWS Lambda container shutdown (timeout and/or spin-down).

:warning: You have 500 milliseconds to complete all of your callbacks before function shutdown.

Installation

You can add leanser package into your AWS Lambda function either by NPM package or by AWS Lambda layer as shown below:

By NPM package

To install the middleware, you can use NPM:

npm install --save leanser

By AWS Lambda Layer

You can also add leanser as layer into your AWS Lambda function.

arn:aws:lambda:${region}:273094347961:layer:leanser:${layer-version}

Latest layer version: leanser (badge powered by Globadge serverless)

Note: In the ARN above, you need to replace ${region} with the actual AWS region you deployed your AWS Lambda function.

Usage

const { register } = require('leanser');

async function myCleaner() {
    // Run your custom cleanup logic (close connections, etc ...)  
};

async function myAnotherCleaner() {
    // Run your another custom cleanup logic (close connections, etc ...)  
};

register(myCleaner, myAnotherCleaner);

exports.handler = async function(event, context) {
    // Do something meaningful

    return {
        statusCode: 200,
    }
};

Configuration

  • Optionally, you can disable/enable cleaner.

    • By environment variable: Set LEANSER_ENABLE environment variable to false to disable cleaner or to true (which is default) to enable cleaner back.
    LEANSER_ENABLE=false
    

Contributing

Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.

License

Licensed under MIT License.

Keywords

serverless

FAQs

Package last updated on 30 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts