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

@stone-js/node-http-adapter

v0.2.0

Published

Node HTTP adapter for Stone.js. Run your app on any Node.js HTTP server using the Continuum Architecture.

Readme

Stone.js - Node HTTP Adapter

npm npm npm Maintenance Build Status Publish Package to npmjs Quality Gate Status Coverage Security Policy CodeQL Dependabot Status Conventional Commits

The Node HTTP Adapter enables your Stone.js application to run in any Node.js HTTP environment. It provides a low-level bridge between raw Node HTTP events and the internal event system of Stone.js, fully aligned with the Continuum Architecture.


Introduction

In Stone.js, adapters are the translation layer between the outside world and your internal logic. The Node HTTP Adapter handles incoming HTTP requests from Node’s built-in http module, transforming them into standardized IncomingEvent objects, and turning your system’s OutgoingResponse back into proper HTTP responses.

This adapter allows your Stone.js app to behave like a traditional web server, without requiring Express or any framework overhead, while still benefiting from Stone.js’s unified event model, clean lifecycle, and platform independence.

Installation

npm install @stone-js/node-http-adapter

This package is pure ESM. Make sure your project uses ESM ("type": "module" in package.json) or configure your tooling accordingly.

Usage

You can integrate the adapter either declaratively with a decorator or imperatively using the nodeHttpAdapterBlueprint.

Declarative API

import { NodeHttp } from '@stone-js/node-http-adapter'
import { StoneApp, IncomingEvent, IEventHandler } from '@stone-js/core'

@StoneApp()
@NodeHttp({ url: 'http://localhost:8081' })
export class Application implements IEventHandler<IncomingEvent> {
  handle(event: IncomingEvent) {
    const name = event.get<string>('name', 'World')
    return { message: `Hello ${name}` }
  }
}

Imperative API

import { defineStoneApp, IncomingEvent, defineConfig, IBlueprint } from '@stone-js/core'
import { nodeHttpAdapterBlueprint, NODE_HTTP_PLATFORM } from '@stone-js/node-http-adapter'

const handler = (event: IncomingEvent) => {
  const name = event.get<string>('name', 'World')
  return { message: `Hi ${name}` }
}

export const App = defineStoneApp(handler, {}, [nodeHttpAdapterBlueprint])

export const AppConfig = defineConfig({
  afterConfigure(blueprint: IBlueprint) {
    if (blueprint.is('stone.adapter.platform', NODE_HTTP_PLATFORM)) {
      blueprint.set('stone.adapter.url', 'http://localhost:8081')
    }
  }
})

What It Enables

  • Universal HTTP Support Run your Stone.js app on any Node.js HTTP server. No Express or external framework needed.

  • Full Continuum Integration HTTP becomes a native dimension of your system: requests and responses are transformed into IncomingEvent and OutgoingResponse, respecting the Continuum model.

  • Server-Level Middleware Add serverMiddleware[] to intercept raw HTTP traffic before Stone.js handles it. Works with most connect-style middlewares.

  • Lifecycle and Hook Support Includes support for onStart, onStop, error hooks, and adapter middleware pipelines.

  • Rich Event Context Access IP, cookies, headers, body, uploaded files, and more in a normalized and typed format.

  • Streaming & File Uploads Direct access to Node’s IncomingMessage and ServerResponse for advanced use cases like streaming or file handling.

  • First-Class TypeScript Support Strong typings for all configuration, events, and response types.

  • Built-in Error Handling Customize how errors are caught and transformed into HTTP responses.

Configuration Options

| Option | Type | Description | | -------------------- | ----------------------------------------- | --------------------------------------------------------------- | | url | string | Base URL of the server. Example: http://localhost:3000 | | isSsl | boolean | Whether to use HTTPS | | server | NodeServerOptions | Native Node server configuration | | printUrls | boolean | Log URL(s) to console on server start | | serverMiddleware[] | Array<(req, res, next) => void> | Platform-level connect-like middleware before Stone.js kicks in | | alias | string | Optional name for referencing the adapter | | default | boolean | Set as default adapter for the app | | current | boolean | Mark this as the active adapter during runtime | | middleware[] | AdapterMixedPipeType[] | Middleware for request/response within the Stone.js lifecycle | | errorHandlers | Record<string, MetaAdapterErrorHandler> | Fine-grained adapter-level error handling |

Adapter Context Shape

When middleware or integration hooks execute, they receive the following context object:

interface NodeHttpAdapterContext {
  rawEvent: IncomingMessage;
  rawResponse?: ServerResponse;
  executionContext: NodeHttpServer;
  incomingEvent?: IncomingHttpEvent;
  outgoingResponse?: OutgoingHttpResponse;
  incomingEventBuilder: IAdapterEventBuilder<IncomingHttpEventOptions, IncomingHttpEvent>;
  rawResponseBuilder: IAdapterEventBuilder<RawHttpResponseOptions, IRawResponseWrapper<ServerResponse>>;
}

These values expose the full HTTP lifecycle and provide access to Stone.js event builders.

Incoming HTTP Event Options

interface IncomingHttpEventOptions {
  url: URL;
  ip: string;
  ips?: string[];
  protocol?: string;
  method?: HttpMethods;
  queryString?: string;
  cookies?: CookieCollection;
  body?: Record<string, unknown>;
  files?: Record<string, UploadedFile[]>;
  headers?: Record<string, string> | Headers;
}

Raw HTTP Response Options

interface RawHttpResponseOptions {
  body: unknown;
  charset?: string;
  statusCode: number;
  statusMessage: string;
  headers: Map<string, string> | Headers;
  streamFile?: () => void | Promise<void>;
}

This context flows through all adapter middleware and hooks.

Summary

The @stone-js/node-http-adapter brings your Stone.js application to life in the HTTP world. With seamless integration, native Node support, and complete event transformation, you can build modern APIs, websites, or microservices that feel as fast and flexible as Node, but with the architectural rigor of Stone.js.

Learn More

This package is part of the Stone.js ecosystem, a modern JavaScript framework built around the Continuum Architecture.

Explore the full documentation: https://stonejs.dev

API documentation

Contributing

See Contributing Guide