Git Diffビューアー
構文ハイライトと左右比較に対応したGit diffビューアーです。
コンテキスト
変更前のコード
変更後のコード
行ごとの差分 (Diff)
+8 行追加-4 行削除
| 1 | import { readCache, writeCache } from './cache'; | 1 | import { deleteCache, readCache, writeCache } from './cache'; |
| 2 | 2 | ||
| 3 | export interface UserSession { | 3 | export interface UserSession { |
| 4 | id: string; | 4 | id: string; |
| 5 | role: 'viewer' | 'editor'; | 5 | role: 'viewer' | 'editor' | 'admin'; |
| 6 | expiresAt: number; | 6 | expiresAt: number; |
| 7 | issuedAt: number; | ||
| 7 | } | 8 | } |
| 8 | 9 | ||
| 9 | export async function refreshSession(token: string): Promise<UserSession | null> { | 10 | export async function refreshSession(token: string): Promise<UserSession | null> { |
| 10 | if (!token) { | 11 | const trimmed = token.trim(); |
| 12 | if (!trimmed) { | ||
| 11 | return null; | 13 | return null; |
| 12 | } | 14 | } |
| 13 | const cached = await readCache(token); | 15 | const cached = await readCache(trimmed); |
| 14 | if (cached && cached.expiresAt > Date.now()) { | 16 | if (cached && cached.expiresAt > Date.now()) { |
| 17 | await writeCache(trimmed, cached); | ||
| 15 | return cached; | 18 | return cached; |
| 16 | } | 19 | } |
| 20 | await deleteCache(trimmed); | ||
| 17 | return null; | 21 | return null; |
| 18 | } | 22 | } |