Pārlūkot izejas kodu

chore: fix build issues

Nicolas Meienberger 1 gadu atpakaļ
vecāks
revīzija
6446eab877

+ 8 - 4
src/app/api/get-status/route.ts

@@ -1,9 +1,13 @@
 import { TipiCache } from '@/server/core/TipiCache';
 
 export async function GET() {
-  const cache = new TipiCache('getStatus');
-  const status = (await cache.get('status')) || 'RUNNING';
-  await cache.close();
+  try {
+    const cache = new TipiCache('getStatus');
+    const status = (await cache.get('status')) || 'RUNNING';
+    await cache.close();
 
-  return Response.json({ success: true, status });
+    return Response.json({ success: true, status });
+  } catch (error) {
+    return Response.json({ success: false, error });
+  }
 }

+ 4 - 2
src/client/components/hoc/StatusProvider/StatusProvider.tsx

@@ -10,7 +10,7 @@ interface IProps {
   children: React.ReactNode;
 }
 
-const fetcher: Fetcher<{ status: SystemStatus }> = () => fetch('/api/get-status').then((res) => res.json() as Promise<{ status: SystemStatus }>);
+const fetcher: Fetcher<{ status?: SystemStatus }> = () => fetch('/api/get-status').then((res) => res.json() as Promise<{ status: SystemStatus }>);
 
 export const StatusProvider: React.FC<IProps> = ({ children }) => {
   const { status, setStatus, pollStatus, setPollStatus } = useSystemStore();
@@ -22,7 +22,9 @@ export const StatusProvider: React.FC<IProps> = ({ children }) => {
     refreshInterval: pollStatus ? 2000 : 0,
     isPaused: () => !pollStatus,
     onSuccess: (res) => {
-      setStatus(res.status);
+      if (res.status) {
+        setStatus(res.status);
+      }
     },
   });
 

+ 0 - 4
src/server/core/TipiCache/TipiCache.ts

@@ -15,10 +15,6 @@ export class TipiCache {
       password: getConfig().redisPassword,
     });
 
-    client.on('error', (err) => {
-      Logger.error(`Redis error: ${err}`);
-    });
-
     this.client = client as RedisClientType;
 
     this.timeout = setTimeout(() => {