0337GitHub
hono-jev-router
Routes Hono HTTP requests by meaning.
yusukebe/hono-jev-routerREADME ↗
# hono-jev-router
Route HTTP requests by meaning.
`hono-jev-router` is an experimental router for [Hono](https://hono.dev). Instead of a method and a path, you describe a request in plain words, and [Jev](https://typesafe.ai) by TypeSafe AI decides which description fits the incoming request.
```ts
import { Hono } from 'hono'
import { JevRouter } from 'hono-jev-router'
const app = new Hono({
router: new JevRouter({ apiKey: process.env.TYPESAFE_API_KEY }),
})
app.on('jev', 'a request from an AI agent', (c) => {
return c.text('# Documentation', 200, { 'Content-Type': 'text/markdown' })
})
app.on('jev', 'a request from a human browser', (c) => {
return c.html('<h1>Documentation</h1>')
})
app.on('jev', 'suspicious automated traffic', (c) => {
return c.text('Forbidden', 403)
})
export default app
```
> [!WARNING]
> This is an experiment. Every semantically routed request calls a model, so it adds latency and cost, and the answer is a probability, not a guarantee.
## Before you use it
- **Do not use it for authentication or authorization.** The request is the input of the model, so whoever sends the request can try to steer the answer. `'suspicious automated traffic'` is a heuristic, not a security boundary.
- **Requests are sent to a third party.** The method, URL, headers and the first `maxBodyLength` bytes of a textual body go to Jev. The values of `Authorization`, `Cookie`, `Proxy-Authorization`, `X-API-Key` and `X-Auth-Token` are replaced with `[redacted]`. Change the list with `redactHeaders`.
- **Every semantically routed request is a model call you pay for.** Put a rate limit in front of it.
## Install
```bash
npm i hono-jev-router
```
## How it works
```
HTTP Request → JevRouter → Jev: "does the request match this description?" → first match →