JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q71934F
  • License MIT

VoltX Server — Hono-based HTTP server with file-based routing, SSE streaming, and static file serving

Package Exports

  • @voltx/server

Readme

@voltx/server
Hono-based HTTP server with file-based routing and SSE streaming

npm downloads license


The HTTP layer of the VoltX framework. Built on Hono with file-based routing (Next.js-style), CORS, logging, error handling, and static file serving out of the box.

Installation

npm install @voltx/server

Quick Start

import { createServer } from "@voltx/server";

const server = createServer({
  port: 3000,
  routesDir: "src/routes",
  cors: true,
  logger: true,
});

await server.start();
// ⚡ VoltX server running at http://localhost:3000

File-Based Routing

Drop files in src/routes/ and they become API endpoints automatically:

src/routes/index.ts           → GET /
src/routes/api/chat.ts        → POST /api/chat
src/routes/api/users/[id].ts  → GET /api/users/:id
src/routes/api/[...slug].ts   → /api/* (catch-all)

Each file exports HTTP method handlers:

// src/routes/api/chat.ts
import type { Context } from "@voltx/server";

export async function POST(c: Context) {
  const body = await c.req.json();
  return c.json({ message: "Hello!" });
}

export function GET(c: Context) {
  return c.json({ status: "ok" });
}

Features

  • File-based routing — Next.js-style, zero config
  • Dynamic routes[param]:param, [...slug] → catch-all
  • Built-in middleware — CORS, request logging, error handling
  • Static file serving — Serves from public/ directory
  • Per-route middleware — Export middleware from any route file
  • Graceful shutdown — Clean server stop with server.stop()
  • Full Hono accessserver.app gives you the raw Hono instance

Configuration

Option Type Default Description
port number 3000 Server port
hostname string "0.0.0.0" Bind address
routesDir string "src/routes" Routes directory
staticDir string "public" Static files directory
cors boolean | object true CORS configuration
logger boolean true (dev) Request logging

Part of VoltX

This package is part of the VoltX framework. See the monorepo for full documentation.

License

MIT — Made by the Promptly AI Team