swiftjs-core
v0.8.2
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 radix tree router with 53k+ req/sec.
- 📁 File-based Routing - Next.js-style automatic route discovery.
- 🔒 Type-safe - End-to-end type safety with Zod validation.
- 🔌 Plugin System - Fastify-inspired extensible architecture.
- 📊 Observability - Built-in Prometheus metrics, tracing, and health checks.
- 🕒 Jobs & Scheduling - Native task scheduler for Cron and background jobs.
- 🛡️ Security - CSRF protection, SQLi detection, and security headers.
- 📡 Real-time - Seamless WebSockets and Server-Sent Events (SSE).
- 🌐 Multi-runtime - Run anywhere: Node.js, Bun, or Edge.
Installation
npm install swiftjs-core zodQuick Start
import { createApp } from 'swiftjs-core';
const app = createApp({ port: 3000 });
// Simple route
app.get('/', () => ({ message: 'Hello SwiftJS!' }));
// Route with params
app.get('/users/:id', (ctx) => ({
userId: ctx.params.id
}));
// Route with validation
import { z } from 'swiftjs-core';
app.post('/login', (ctx) => {
return { success: true };
}, {
body: z.object({
username: z.string(),
password: z.string()
})
});
app.listen();File-based Routing
SwiftJS automatically maps files in your routes directory to URLs.
src/routes/
├── index.get.ts → GET /
├── users.post.ts → POST /users
└── users/[id].get.ts → GET /users/:idAdvanced Features
Observability
import { observabilityPlugin } from 'swiftjs-core';
app.register(observabilityPlugin());Background Jobs
import { jobsPlugin } from 'swiftjs-core';
app.register(jobsPlugin());
app.scheduler.addJob({
name: 'cleanup',
schedule: { cron: '0 0 * * *' },
handler: async () => { /* ... */ }
});Documentation
For full documentation, visit the docs directory or the official website.
License
MIT
