nestjs-platform-elysia
v0.2.0
Published
NestJS HTTP adapter for the Elysia web framework on Bun
Downloads
712
Maintainers
Readme
nestjs-platform-elysia
NestJS HTTP adapter for Elysia on Bun.
⚠️ Bun runtime only. Elysia uses
Bun.serve()internally and does not run on Node.js.
Why
NestJS gives you DI, modules, guards, pipes, interceptors, exception filters. Elysia gives you Bun-native performance, end-to-end type safety, TypeBox/Zod validation at the framework level, lifecycle hooks, and a plugin ecosystem.
This adapter lets you keep both: write Nest controllers as usual while still being able to register Elysia plugins, attach TypeBox schemas, mount sub-apps, and use app.handle() for testing — without losing what makes Elysia worth choosing.
Install
bun add nestjs-platform-elysia @nestjs/common @nestjs/core elysiaQuick start
import { NestFactory } from '@nestjs/core';
import { ElysiaAdapter, type NestElysiaApplication } from 'nestjs-platform-elysia';
import { AppModule } from './app.module';
const app = await NestFactory.create<NestElysiaApplication>(
AppModule,
new ElysiaAdapter(),
);
await app.listen(3000);Guides
| Guide | What's inside |
|---|---|
| Getting Started | Install, bootstrap, project layout |
| Route Decorators | @RouteSchema, @RouteHook, @RouteConfig, @RouteDetail |
| Body Parsing | rawBody, custom parsers, size limits |
| Server-Sent Events | @Sse() over Web Streams, backpressure, disconnects |
| File Uploads | Native multipart, @UploadedFile(), @UploadedFiles() |
| Static Assets | useStaticAssets(), Range requests, traversal protection |
| Trust Proxy | X-Forwarded-* resolution, Express-compatible hop count |
| WebSockets | @WebSocketGateway on the same Bun server, hardening config |
| Testing | app.inject() patterns, fixtures |
| API Reference | Adapter, request, reply, interfaces |
What's supported
- All HTTP methods, route params, query, body, default status codes
- Full Nest pipeline: Guards, Pipes, Interceptors, Exception Filters
@RouteSchemawith TypeBox/Zod for framework-level validation- Versioning: URI, Header, Media-Type, Custom
- CORS via
@elysiajs/cors MiddlewareConsumer.apply().forRoutes()(Express-style middleware)- Server-Sent Events (
@Sse()) streamed over Web Streams, with client-disconnect cleanup - File uploads via native multipart —
@Body(),@UploadedFile(),@UploadedFiles()yield WebFileobjects (no multer) - Static file serving via
useStaticAssets(root, { prefix }), backed byBun.filewith path-traversal protection - Hybrid apps: HTTP server + Nest microservices (TCP validated)
app.register(plugin)for Elysia plugins (swagger, bearer, openapi, etc.)app.mount(path, handler)for sub-apps and fetch handlersapp.inject(Request)for programmatic testing- WebSocket gateways on the same Bun server (no second port)
Known limitations
setViewEngine()/@Render()— not implemented (no SSR templating support).@Req()/@Res()— receiveElysiaRequest/ElysiaReplywrappers, not Express request/response. Express-only APIs like.is(),.accepts(),.signedCookiesare not exposed.- Microservice transports are runtime-dependent — each transport must support Bun (TCP validated; others untested).
Versioning
Pre-1.0. APIs may change between minor versions. See CHANGELOG.md.
Releasing
Releases are cut by pushing a v*.*.* tag — see .github/workflows/release.yml. The workflow runs bun run check, verifies the tag matches package.json#version, publishes to npm via OIDC Trusted Publishing with provenance, and creates a GitHub Release.
