feat: implement authentication middleware and routes

- Added `auth.ts` for JWT authentication middleware.
- Created `auth` route to handle authentication and token verification.
- Integrated authentication middleware into `media.ts` for protected routes.
- Updated `main.ts` to register the new authentication route.
This commit is contained in:
ethan.chen
2025-06-23 16:57:22 +08:00
parent e511ab9db6
commit 32f7b86f28
5 changed files with 59 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ import { jwt } from 'hono/jwt'
import type { JwtVariables } from 'hono/jwt'
import user from './routes/user.ts'
import media from './routes/media.ts'
import auth from './routes/auth.ts'
const app = new Hono<{ Variables: JwtVariables }>()
@@ -20,6 +21,9 @@ app.use('*', async (c, next) => {
await next()
})
// 注册认证路由
app.route('/api/auth', auth)
// 注册用户路由
app.route('/api/user', user)