npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gasket-plugin-lambda

v0.1.0

Published

Adds AWS Lambda support to your Gasket application

Readme

gasket-plugin-lambda

A Gasket plugin that adds AWS Lambda support to your application. This plugin allows you to create serverless applications using the Gasket framework by providing a Lambda handler that works with AWS Lambda API Gateway events.

Installation

pnpm add gasket-plugin-lambda

Configuration

Add the plugin to your Gasket application:

// gasket.ts
import { makeGasket } from '@gasket/core';
import pluginLambda from 'gasket-plugin-lambda';

export default makeGasket({
  plugins: [
    pluginLambda,
    // other plugins...
  ],
  lambda: {
    // Enable/disable request logging
    logger: true,
    // CORS configuration
    cors: {
      allowOrigin: '*',
      allowMethods: 'GET,POST,PUT,DELETE,OPTIONS',
      allowHeaders: 'Content-Type,Authorization'
    }
  }
});

Usage

Create a Lambda handler file that imports your Gasket instance and uses the createHandler action:

// lambda.ts
import gasket from './gasket.js';

export const handler = await gasket.actions.createHandler();

Lifecycles

lambdaMiddleware

Add middleware to the Lambda handler:

// plugins/my-middleware.ts
import type { Plugin } from '@gasket/core';

const myMiddleware: Plugin = {
  name: 'my-middleware',
  hooks: {
    lambdaMiddleware(gasket, handler) {
      return async (event, context, next) => {
        console.log('Request received:', event.path);
        await next();
      };
    }
  }
};

export default myMiddleware;

lambda

The lambda lifecycle allows you to transform or replace the Lambda handler. This is particularly useful for integrating web frameworks like Hono:

// plugins/lambda-handler-plugin.ts
import { Plugin } from "@gasket/core";
import { Hono } from "hono";
import { handle } from "hono/aws-lambda";

const pluginLambdaHandler: Plugin = {
  name: 'lambda-handler',
  hooks: {
    lambda: async (gasket, handler) => {
      const hono = new Hono();
      await gasket.exec('hono', hono);
      return handle(hono);
    }
  }
};

export default pluginLambdaHandler;

lambdaErrorMiddleware

Add error handling middleware:

// plugins/error-handler.ts
import type { Plugin } from '@gasket/core';

const errorHandler: Plugin = {
  name: 'error-handler',
  hooks: {
    lambdaErrorMiddleware(gasket) {
      return async (err, event, context) => {
        console.error('Error in Lambda handler:', err);
        return {
          statusCode: 500,
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({ 
            error: 'Internal Server Error',
            message: err.message
          })
        };
      };
    }
  }
};

export default errorHandler;

Framework Integration

Hono

The plugin works seamlessly with Hono's AWS Lambda adapter. Create a plugin that implements the lambda hook to integrate Hono:

// plugins/lambda-handler-plugin.ts
import { Plugin } from "@gasket/core";
import { Hono } from "hono";
import { handle } from "hono/aws-lambda";

const pluginLambdaHandler: Plugin = {
  name: 'lambda-handler',
  hooks: {
    lambda: async (gasket, handler) => {
      const hono = new Hono();
      await gasket.exec('hono', hono);
      return handle(hono);
    }
  }
};

export default pluginLambdaHandler;

Then create a routes plugin to add endpoints to your Hono app:

// plugins/routes-plugin.ts
import type { Plugin } from '@gasket/core';

const routesPlugin: Plugin = {
  name: 'routes-plugin',
  hooks: {
    async hono(gasket, app) {
      app.get('/api/hello', (c) => {
        return c.json({
          message: 'Hello from Lambda!',
          timestamp: new Date().toISOString()
        });
      });
      
      // Add more routes...
    }
  }
};

export default routesPlugin;

Type Definitions

To properly support both standard Lambda handlers and Hono's handler, you may need to update your type definitions:

// In your plugin's index.ts
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, Context } from 'aws-lambda';

// Define a flexible handler type
export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
type LambdaHandler = (event: any, context?: any) => Promise<APIGatewayProxyResult>;

// Then use this type in your hook definitions

Example Project

For a complete example of using this plugin with Hono, see the hono-api-lambda project.

License

MIT