Authorized routes
未關閉
enhancement
roadmap
- 主要語言
- TypeScript
- 星號
- 38
- 分支
- 1
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### ⚠️ The example in this OP is outdated. See https://github.com/alloc/saus/issues/56#issuecomment-1143963756
---
Add an `authorizeRoutes` route hook, used like so:
```ts
// ./src/node/routes.ts
import { authorizeRoutes, Redirect } from 'saus'
// The route pattern is optional. If none is provided, all routes are authenticated.
authorizeRoutes('*', async (headers, url) => {
if (verify(headers)) {
return true
}
// Redirect the request, or return false to act like this route doesn't exist.
return new Redirect('/login')
})
const verify = (headers) => {
// TODO: verify a Cookie header or JWT token, etc
}
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。