alloc / alloc/saus

Authorized routes

オープン
#56 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。