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

koatty_serverless

v1.0.5

Published

Serverless adapter for Koatty framework

Readme

koatty_serverless

Serverless adapter for Koatty framework - deploy to AWS Lambda, Alibaba Cloud FC, Tencent SCF.

Installation

npm install koatty_serverless

For AWS Lambda, also install the optional dependency:

npm install @codegenie/serverless-express

Quick Start

AWS Lambda

// src/lambda.ts
import { createHandler } from 'koatty_serverless';
import { App } from './App';

export const handler = createHandler(App, {
  platform: 'aws',
  healthCheck: async (app) => {
    // Check database connections after Lambda thaw
    // const ds = IOC.get('TypeormStore')?.getDataSource();
    // if (ds && !ds.isInitialized) await ds.initialize();
  },
  eventHandlers: {
    scheduled: async (event, context, app) => {
      // Handle CloudWatch scheduled events
      return { statusCode: 200 };
    },
  },
});

Alibaba Cloud Function Compute (FC)

// src/fc.ts
import { createHandler } from 'koatty_serverless';
import { App } from './App';

export const handler = createHandler(App, { platform: 'alicloud' });

Tencent Cloud SCF

// src/scf.ts
import { createHandler } from 'koatty_serverless';
import { App } from './App';

export const handler = createHandler(App, { platform: 'tencent' });

Without koatty-serverless

For platforms like Alibaba Cloud FC HTTP trigger where the input is already a standard HTTP object:

// src/handler.ts
import { createApplication } from 'koatty';
import { App } from './App';

let handler: (req: any, res: any) => Promise<any>;

export async function httpHandler(req: any, resp: any, context: any) {
  if (!handler) {
    const app = await createApplication(App);
    handler = app.getRequestHandler();
  }
  return handler(req, resp);
}

API Reference

createHandler(AppClass, options?)

Creates a serverless handler function.

Parameters:

  • AppClass - Your Koatty application class
  • options - Configuration options

Options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | platform | 'aws' \| 'alicloud' \| 'tencent' | 'aws' | Target cloud platform | | adapter | ServerlessAdapter | - | Custom adapter (overrides platform) | | bootFunc | Function | - | Custom bootstrap function | | eventHandlers | Record<string, EventHandler> | - | Non-HTTP event handlers | | healthCheck | (app) => Promise<void> | - | Health check before each invocation |

EventHandler

type EventHandler = (
  event: any,
  context: any,
  app: KoattyApplication,
) => Promise<any>;

ServerlessAdapter Interface

interface ServerlessAdapter {
  readonly name: string;
  createHandler(app: KoattyApplication): (...args: any[]) => Promise<any>;
}

Custom Adapters

Implement ServerlessAdapter for other platforms:

import type { ServerlessAdapter } from 'koatty_serverless';
import type { KoattyApplication } from 'koatty_core';

class CloudflareAdapter implements ServerlessAdapter {
  readonly name = 'cloudflare-workers';

  createHandler(app: KoattyApplication) {
    const httpHandler = app.getRequestHandler();
    return async (request: Request) => {
      // Convert Cloudflare Request to Node.js HTTP format
      // ...
    };
  }
}

// Usage
export const handler = createHandler(App, {
  adapter: new CloudflareAdapter(),
});

License

BSD-3-Clause