sinwan-engine
v1.0.5
Published
Server framework for building modern distributed applications. Unified runtime for HTTP, WebSocket, TCP, UDP, and gRPC — APIs, real-time systems, microservices, and event-driven apps from a single engine.
Maintainers
Readme
Sinwan Engine gives you a step-based middleware pipeline, a typed event bus, a deterministic lifecycle manager, context pooling, and protocol routers for HTTP, WebSocket, TCP, UDP, and gRPC — all from a single Sinwan application instance built on Bun.
Install
bun add sinwan-engineRequires Bun runtime.
Quick Start
import { Sinwan } from "sinwan-engine";
const app = await Sinwan.create();
app
.get("/", (ctx) => ctx.json({ hello: "world" }))
.get("/users/:id", (ctx) => ctx.json({ id: ctx.params.id }))
.post("/users", async (ctx) => {
const body = await ctx.parseBody();
ctx.json({ created: body }, 201);
});
await app.listen(3000, ({ port }) => {
console.log(`Server live on http://localhost:${port}`);
});Features
- Multi-protocol: HTTP, WebSocket, TCP, UDP, and gRPC from one engine
- Step pipeline: Named, deterministic middleware steps — no
next()chaining - Event bus: Typed events with wildcards, AbortSignal support, and tracing
- Lifecycle manager: Five-phase lifecycle (
idle → init → ready → shutdown → destroyed) - Context pooling: Reusable per-request context with state, global state, and response helpers
- Response helpers:
json,text,html,redirect,stream,iterate,sse,buffer,file - Plugin system: Encapsulate features as installable plugins
- Module system: Group routes into reusable modules (
createHttpModule,createWSModule, …) - gRPC support: Optional — install
sinwan-grpcto enable typed gRPC services - Static files: Serve directories with
app.static(prefix, root) - Internal assets: Built-in favicon and robots.txt handling
Development
bun test
bun run typecheck
bun run buildAuthor
Mohammed Ben Cheikh
License
MIT — see LICENSE.
