From 3f72c9440ab0075472e76b923b1e1b5f727eafc1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Dec 2024 14:40:43 +0000 Subject: [PATCH] format: make the code prettier --- apps/api/app/v1/[[...route]]/user.ts | 14 ++++--- apps/api/app/v1/[[...route]]/workspace.ts | 51 +++++++++++++++++------ 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/apps/api/app/v1/[[...route]]/user.ts b/apps/api/app/v1/[[...route]]/user.ts index 1517c4c..6edd84d 100644 --- a/apps/api/app/v1/[[...route]]/user.ts +++ b/apps/api/app/v1/[[...route]]/user.ts @@ -28,7 +28,7 @@ const app = new Hono() message: "Oops! seems like your session is expired", status: 400, }, - 400 + 400, ); } @@ -68,10 +68,11 @@ const app = new Hono() const cursor = c.req.query("cursor"); const take = parseInt(c.req.query("take") || "10"); const cacheKey = `users:all:${cursor || "start"}:${take}`; - let response: { nextCursor: string | null, users: User[] } | null = null; + let response: { nextCursor: string | null; users: User[] } | null = null; try { - const cachedData: { nextCursor: string | null, users: User[] } | null = await cache.get(cacheKey); + const cachedData: { nextCursor: string | null; users: User[] } | null = + await cache.get(cacheKey); if (cachedData) { response = cachedData; console.log("Returned user list from cache"); @@ -142,7 +143,10 @@ const app = new Hono() try { await cache.set(cacheKey, user, { ex: CACHE_EXPIRY }); } catch (cacheError) { - console.error("Error storing user data in cache (by ID):", cacheError); + console.error( + "Error storing user data in cache (by ID):", + cacheError, + ); } } } @@ -150,4 +154,4 @@ const app = new Hono() return c.json({ user }, 200); }); -export default app; \ No newline at end of file +export default app; diff --git a/apps/api/app/v1/[[...route]]/workspace.ts b/apps/api/app/v1/[[...route]]/workspace.ts index 58988af..03d8664 100644 --- a/apps/api/app/v1/[[...route]]/workspace.ts +++ b/apps/api/app/v1/[[...route]]/workspace.ts @@ -21,10 +21,16 @@ const app = new Hono() const cursor = c.req.query("cursor"); const take = parseInt(c.req.query("take") || "10"); const cacheKey = `workspaces:all:${cursor || "start"}:${take}`; - let response: { nextCursor: string | null, workspaces: Workspace[] } | null = null; + let response: { + nextCursor: string | null; + workspaces: Workspace[]; + } | null = null; try { - const cachedData: { nextCursor: string | null, workspaces: Workspace[] } | null = await cache.get(cacheKey); + const cachedData: { + nextCursor: string | null; + workspaces: Workspace[]; + } | null = await cache.get(cacheKey); if (cachedData) { response = cachedData; console.log("Returned workspace list from cache"); @@ -51,14 +57,18 @@ const app = new Hono() }, }); - const nextCursor = workspaces.length > 0 ? workspaces[workspaces.length - 1].id : null; + const nextCursor = + workspaces.length > 0 ? workspaces[workspaces.length - 1].id : null; response = { nextCursor, workspaces }; console.log("Fetched workspace list from database (all)"); try { await cache.set(cacheKey, response, { ex: CACHE_EXPIRY }); } catch (cacheError) { - console.error("Error storing workspace list in cache (all):", cacheError); + console.error( + "Error storing workspace list in cache (all):", + cacheError, + ); } } @@ -98,7 +108,10 @@ const app = new Hono() try { await cache.set(cacheKey, workspace, { ex: CACHE_EXPIRY }); } catch (cacheError) { - console.error("Error storing workspace data in cache (by ID):", cacheError); + console.error( + "Error storing workspace data in cache (by ID):", + cacheError, + ); } } @@ -161,19 +174,24 @@ const app = new Hono() const workspace = await prisma.workspace.create({ data: { name: body.name, - userId: userId + userId: userId, }, }); if (!workspace) { - return c.json({ message: "failed to create workspace", status: 404 }, 404); + return c.json( + { message: "failed to create workspace", status: 404 }, + 404, + ); } // Invalidate cache for user workspaces const userWorkspacesCacheKey = `workspaces:user:${userId}`; try { await cache.del(userWorkspacesCacheKey); - console.log(`Invalidated cache for user workspaces: ${userWorkspacesCacheKey}`); + console.log( + `Invalidated cache for user workspaces: ${userWorkspacesCacheKey}`, + ); } catch (cacheError) { console.error("Error invalidating user workspaces cache:", cacheError); } @@ -217,15 +235,22 @@ const app = new Hono() try { await Promise.all([ cache.del(specificWorkspaceCacheKey), - cache.del(userWorkspacesCacheKey) + cache.del(userWorkspacesCacheKey), ]); - console.log(`Invalidated cache for workspace: ${specificWorkspaceCacheKey}`); - console.log(`Invalidated cache for user workspaces: ${userWorkspacesCacheKey}`); + console.log( + `Invalidated cache for workspace: ${specificWorkspaceCacheKey}`, + ); + console.log( + `Invalidated cache for user workspaces: ${userWorkspacesCacheKey}`, + ); } catch (cacheError) { - console.error("Error invalidating workspace and user workspaces cache:", cacheError); + console.error( + "Error invalidating workspace and user workspaces cache:", + cacheError, + ); } return c.json({ deletedWorkspace: workspace }, 200); }); -export default app; \ No newline at end of file +export default app;