Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇

feat(monitor/frontend): useSnapshot hook (single bootstrap, no refetch)

CarterPerez-dev6aa3efacd6d9
diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts b/PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts
new file mode 100644
index 00000000..3c4365da
--- /dev/null
+++ b/PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts
@@ -0,0 +1,21 @@
+// ©AngelaMos | 2026
+// snapshot.ts
+
+import { useQuery } from '@tanstack/react-query'
+import { apiClient } from '@/core/api'
+
+export type Snapshot = Record<string, unknown>
+
+export const SNAPSHOT_KEY = ['snapshot'] as const
+
+export function useSnapshot() {
+ return useQuery({
+ queryKey: SNAPSHOT_KEY,
+ queryFn: async (): Promise<Snapshot> => {
+ const res = await apiClient.get<Snapshot>('/v1/snapshot')
+ return res.data
+ },
+ staleTime: Number.POSITIVE_INFINITY,
+ gcTime: Number.POSITIVE_INFINITY,
+ })
+}