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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@asterflow/adapter

v1.0.14

Published

<div align="center">

Readme

@asterflow/adapter

license-info stars-info last-commit

bundle-size

HTTP adapters for the AsterFlow framework, providing a unified interface for different runtimes.

📦 Installation

npm install @asterflow/adapter
# or
bun install @asterflow/adapter

💡 About

@asterflow/adapter is an HTTP adapter system that allows AsterFlow applications to run on different execution environments. The package provides an abstraction layer that unifies the interface of different HTTP servers, allowing you to write your code once and run it on any supported runtime.

✨ Features

  • Multiple Runtimes: Native support for:
    • Node.js HTTP Server
    • Bun
    • Express
    • Fastify
  • Unified Interface: Consistent API regardless of runtime
  • Error Handling: Robust error handling system with standardized responses
  • Strong Typing: Full TypeScript support with type inference
  • Router Integration: Works seamlessly with AsterFlow's routing system
  • Zero Configuration: Works immediately after installation
  • Middleware Support: Compatible with runtime-specific middleware

🚀 Usage

Basic Example

import { AsterFlow } from 'asterflow'
import { adapters } from '@asterflow/adapter'
import { Router } from '@asterflow/router'

// Create an AsterFlow instance with the desired adapter
const app = new AsterFlow({ 
  driver: adapters.node // or adapters.bun, adapters.express, adapters.fastify
})

// Define your routes
const router = new Router({
  path: '/hello',
  methods: {
    get({ response }) {
      return response.send('Hello World!')
    }
  }
})

// Register routes
app.controller(router)

// Start the server
app.listen({ port: 3000 })

Available Adapters

Node.js HTTP Server

import { AsterFlow } from 'asterflow'
import { adapters } from '@asterflow/adapter'

const app = new AsterFlow({
  driver: adapters.node
})

app.listen({ port: 3000 })

Bun

import { AsterFlow } from 'asterflow'
import { adapters } from '@asterflow/adapter'

const app = new AsterFlow({
  driver: adapters.bun
})

app.listen({ port: 3000 })

Express

import { AsterFlow } from 'asterflow'
import { adapters } from '@asterflow/adapter'
import express from 'express'

const expressApp = express()
const app = new AsterFlow({
  driver: adapters.express
})

// Use Express middleware
expressApp.use(express.json())

app.listen(expressApp, 3000)

Fastify

import { AsterFlow } from 'asterflow'
import { adapters } from '@asterflow/adapter'
import fastify from 'fastify'

const server = fastify()
const app = new AsterFlow({
  driver: adapters.fastify
})

app.listen(server, { port: 3000 }, (err) => {
  if (err) {
    console.error(err)
    process.exit(1)
  }
  console.log('Server listening!')
})

🔧 Architecture

Adapter System

The package uses an adapter system that implements the Adapter interface:

class Adapter<Type extends Runtime> {
  readonly runtime: Type
  readonly listen: OptionsDriver<Type>['listen']
  onRequest?: (request: Request, response: Response) => Promise<Response> | Response
}

Each adapter implements:

  • Runtime-specific server initialization
  • Request conversion to AsterFlow format
  • Standardized error handling
  • Integration with the routing system

Error Handling

The system includes robust error handling that:

  • Standardizes error responses
  • Provides stack traces in development environment
  • Logs errors for diagnostics
  • Maintains security by not exposing sensitive details in production
interface ErrorPayload {
  statusCode: number
  error: string
  message: string
  details?: unknown
}

🔗 Related Packages

📄 License

MIT - See LICENSE for more details.