@thekairojs/kairo
v1.0.1
Published
Act at the right moment. Secure from the first line.
Maintainers
Readme
kairo
Core framework. App, router, context, body parser, middleware chain.
npm install @thekairojs/kairoimport { createApp } from '@thekairojs/kairo'
const app = createApp()
app.get('/hello', (ctx) => {
ctx.json({ hello: 'world' })
})
await app.listen(3000)API
createApp(config?)
Returns a KairoAppInstance. Config options:
trustProxy— trustX-Forwarded-Forfor IP extraction. Defaultfalse.ghostRoutes— enable ghost route tracking. Defaulttrue.
Context (ctx)
| Property | Type | Description |
|----------|------|-------------|
| method | HttpMethod | GET, POST, etc. |
| path | string | URL path without query |
| query | Record<string, string> | Parsed query params |
| params | Record<string, string> | Route params (:id, *) |
| headers | Record<string, string> | Request headers |
| body | unknown | Parsed request body |
| ip | string | Client IP |
| kairo | KairoSecurityContext | Security context (entropy, events, lattice…) |
| state | Record<string, unknown> | Per-request middleware state |
Middleware
app.use(async (ctx, next) => {
// before
await next()
// after
})Route groups
const api = app.group('/api', { middleware: [authMiddleware] })
api.get('/users', handler)
api.post('/users', handler)Ghost routes
Decoy endpoints that log and flag any access as suspicious:
app.ghost('/admin/backdoor')
app.ghost('/.env', { alertLevel: 'high' })