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:
4
main.ts
4
main.ts
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user