小橘 d84a860d15 feat: initial ograph repo — engine (85 tests) + cli (31 tests)
Extracted from uncaged monorepo (oc-xiaoju/uncaged).
Resolves oc-xiaoju/uncaged#224.

- @uncaged/ograph: CF Worker engine (events, projections, reactions)
- @uncaged/ograph-cli: CLI for managing OGraph instances
- Removed @uncaged/oid dependency (unused)
- 116 tests, all passing
- CI: GitHub Actions

小橘 🍊(NEKO Team)
2026-04-12 23:43:56 +00:00

22 lines
542 B
TypeScript

import { createMiddleware } from 'hono/factory'
type Env = {
DB: D1Database
API_TOKEN: string
}
export const bearerAuth = (expectedToken: string) =>
createMiddleware<{ Bindings: Env }>(async (c, next) => {
const header = c.req.header('Authorization')
if (!header?.startsWith('Bearer ')) {
return c.json({ error: 'Missing or invalid Authorization header' }, 401)
}
const token = header.slice(7)
if (token !== expectedToken) {
return c.json({ error: 'Invalid token' }, 401)
}
await next()
})