Trình xem Git Diff
Trình xem Git diff có tô sáng cú pháp với chế độ so sánh song song
Ngữ cảnh
Mã nguồn gốc
Mã nguồn đã sửa
So sánh khác biệt từng dòng
+8 dòng thêm-4 dòng xóa
| 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 | } |