activescott / activescott/auth

[FEATURE] @activescott/auth-adapter-hono — Hono framework adapter

未关闭
#27 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
0
派生
1
PR 合并指标
30 天内没有已合并 PR

描述

## Summary

Add `@activescott/auth-adapter-hono` — a Hono adapter for `@activescott/auth`. Works on Node, Cloudflare Workers, Bun, and Deno.

## Motivation

Hono is a fast, lightweight framework that runs everywhere Web standards are available. Because Hono uses standard `Request/Response`, the adapter is extremely thin — no framework-specific quirks. It's the simplest possible adapter and covers a large target audience (especially Cloudflare Workers users).

## API

Same `createAuthHandlers` surface as the React Router adapter, plus three Hono-specific exports:

```ts
import { createAuthHandlers, sendMagicLink } from '@activescott/auth-adapter-hono'
import { requireAuthMiddleware, optionalAuthMiddleware, createAuthHandler } from '@activescott/auth-adapter-hono'
```

**Catch-all auth route:**
```ts
app.all('/auth/:provider/:action', createAuthHandler(handlers))
```

**Protected route middleware:**
```ts
app.use('/dashboard/*', requireAuthMiddleware(handlers))
app.get('/dashboard', (c) => {
const user = c.get('user') as AppUser
return c.json({ user })
})
```

**Optional auth:**
```ts
app.use('/', optionalAuthMiddleware(handlers))
```

## Acceptance Criteria

- [ ] Package `@activescott/auth-adapter-hono` published
- [ ] `createAuthHandlers` — same API as React Router adapter
- [ ] `requireAuthMiddleware` — sets `c.set('user', user)` or returns 302
- [ ] `optionalAuthMiddleware` — sets `c.set('user', user | null)`, never redirects
- [ ] `createAuthHandler` — route handler factory for the catch-all auth route
- [ ] 30 tests passing (21 handler tests + 9 middleware tests)
- [ ] Zero Hono-version-specific dependencies (peer dep `hono ^4.0.0`)

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。