chore: fix build issues
This commit is contained in:
parent
ea4d99df3d
commit
6446eab877
3 changed files with 12 additions and 10 deletions
|
@ -1,9 +1,13 @@
|
||||||
import { TipiCache } from '@/server/core/TipiCache';
|
import { TipiCache } from '@/server/core/TipiCache';
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
const cache = new TipiCache('getStatus');
|
try {
|
||||||
const status = (await cache.get('status')) || 'RUNNING';
|
const cache = new TipiCache('getStatus');
|
||||||
await cache.close();
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ interface IProps {
|
||||||
children: React.ReactNode;
|
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 }) => {
|
export const StatusProvider: React.FC<IProps> = ({ children }) => {
|
||||||
const { status, setStatus, pollStatus, setPollStatus } = useSystemStore();
|
const { status, setStatus, pollStatus, setPollStatus } = useSystemStore();
|
||||||
|
@ -22,7 +22,9 @@ export const StatusProvider: React.FC<IProps> = ({ children }) => {
|
||||||
refreshInterval: pollStatus ? 2000 : 0,
|
refreshInterval: pollStatus ? 2000 : 0,
|
||||||
isPaused: () => !pollStatus,
|
isPaused: () => !pollStatus,
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
setStatus(res.status);
|
if (res.status) {
|
||||||
|
setStatus(res.status);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,6 @@ export class TipiCache {
|
||||||
password: getConfig().redisPassword,
|
password: getConfig().redisPassword,
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('error', (err) => {
|
|
||||||
Logger.error(`Redis error: ${err}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.client = client as RedisClientType;
|
this.client = client as RedisClientType;
|
||||||
|
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
|
|
Loading…
Reference in a new issue