update auth packages

This commit is contained in:
2026-01-27 14:39:38 -03:00
parent f539d78f14
commit 10138112fe
3 changed files with 16 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
import { createContext, redirect, type LoaderFunctionArgs } from 'react-router'
import { userContext } from '@repo/auth/context'
import { requestIdContext, userContext } from '@repo/auth/context'
import { request as req } from '@repo/util/request'
import { CACHE_NAME, CACHE_TTL_SECONDS } from '@/conf'
@@ -42,18 +42,18 @@ export const workspaceMiddleware = async (
next: () => Promise<Response>
): Promise<Response> => {
const orgId = params.orgid
const requestId = context.get(requestIdContext)
const user = context.get(userContext)!
const cacheKey = buildWorkspaceCacheKey(request, user.sub, orgId)
const cached = await getWorkspaceFromCache(cacheKey)
if (cached) {
console.log('Warm start')
context.set(workspaceContext, cached)
return next()
}
console.log('Cache miss')
console.log(`[${new Date().toISOString()}] [${requestId}] Cache miss`)
const r = await req({
url: `/users/${user.sub}/orgs?limit=25`,
@@ -139,7 +139,7 @@ async function saveToCache(
): Promise<void> {
const cache: Cache = await caches.open(CACHE_NAME)
const response: Response = new Response(JSON.stringify(workspace), {
const response = new Response(JSON.stringify(workspace), {
headers: {
'Content-Type': 'application/json',
'Cache-Control': `public, max-age=${CACHE_TTL_SECONDS}`