swiftjs-core
v0.8.0
Published
SwiftJS - A fast, modern, and type-safe web framework for Node.js
Maintainers
Readme
swiftjs-core
A fast, modern, and type-safe web framework for Node.js and Bun.
Features
- 🚀 Blazing Fast - High-performance routing with radix tree
- 📁 File-based Routing - Next.js-style file router (
users.get.ts) - 🔒 Type-safe - Full TypeScript support with Zod validation
- 🔌 Plugin System - Extensible architecture
- 📊 Observability - Built-in health checks, metrics, and tracing
- 🌐 Multi-runtime - Works with Node.js, Bun, and Edge
Installation
npm install swiftjs-coreQuick Start
import { createApp } from 'swiftjs-core';
const app = createApp({ port: 3000 });
app.get('/', () => ({ message: 'Hello SwiftJS!' }));
app.get('/users/:id', (ctx) => ({
userId: ctx.params.id
}));
app.listen();File-based Routing
Create route files with the convention [name].[method].ts:
src/routes/
├── index.get.ts → GET /
├── users.get.ts → GET /users
├── users.post.ts → POST /users
└── users/
└── [id].get.ts → GET /users/:id// src/routes/users.get.ts
export default function handler(ctx) {
return { users: [] };
}
export const summary = 'List users';
export const tags = ['Users'];Validation
import { z, createApp } from 'swiftjs-core';
app.post('/users', (ctx) => {
const { name, email } = ctx.body;
return { id: 1, name, email };
}, {
body: z.object({
name: z.string().min(2),
email: z.string().email()
})
});Plugins
import { createApp, healthPlugin, devToolsPlugin } from 'swiftjs-core';
const app = createApp({ port: 3000 });
app.register(healthPlugin({ basePath: '/health' }));
app.register(devToolsPlugin({ logging: true, timing: true }));Documentation
For full documentation, visit the SwiftJS GitHub repo.
License
MIT
