@voltx/server
v0.3.0
Published
VoltX Server — Hono-based HTTP server with file-based routing, SSE streaming, and static file serving
Maintainers
Readme
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/serverQuick 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:3000File-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
middlewarefrom any route file - Graceful shutdown — Clean server stop with
server.stop() - Full Hono access —
server.appgives 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
