nekochans / lgtm-cat

lgtm-cat(サービス名 LGTMeow https://lgtmeow.com のエピック管理用リポジトリ
0 stars 0 forks source link

Client Credentials Flowで発行したアクセストークンをCacheさせる仕組みを構築する #17

Closed keitakn closed 1 year ago

keitakn commented 2 years ago

Doneの定義

何とかしてサーバー側にCacheさせる方法を考える。

keitakn commented 2 years ago

APICacheの一例として参考になる記事。

https://javascript.plainenglish.io/how-to-cache-api-calls-in-next-js-f4b6aefa84f1

keitakn commented 2 years ago

CloudFlare Workersを使って解決出来ないか?

APIへの直接リクエストをやめてCloudFlare Workersを使って作成したAPI Proxyを通すようにする。

その中でアクセストークンの発行などを行ってしまえばクライアント側から毎回アクセストークンの発行も不要になる。

D1を使えばアクセストークンのCacheも可能になる。

keitakn commented 2 years ago

画像データをbase64で送るのでpayloadサイズの制限に引っかからないかが心配。要検証。

keitakn commented 2 years ago

https://www.publickey1.jp/blog/22/cloudflarecdnsqliterdbcloudflare_d1cdn.html

これを試せるかも。

keitakn commented 1 year ago

これでもいい気がしてきた。

https://planetscale.com/blog/introducing-the-planetscale-serverless-driver-for-javascript

keitakn commented 1 year ago

これもアリ、割と選択肢が多い事に気がつく。

https://zenn.dev/tkithrta/articles/a56603a37b08f0

VercelのEdge API Routesでのサンプルも載っている。

https://upstash.com/blog/next-edge-api

keitakn commented 1 year ago

VercelのEdge Runtime 、CloudFlare Workersだとアカウントを新規で作成しないといけないが、Vercelを使う場合はそれをしなくて良いのがメリットにはなりそう。

https://zenn.dev/yusukebe/articles/f3b130f69287fc

https://vercel.com/features/edge-functions#examples

keitakn commented 1 year ago

Vercelを使う場合は以下を参考に技術検証をしてみる。

https://vercel.com/docs/concepts/functions/edge-functions/quickstart