Catalyst / admin/SAynapse-Horizon 14.8 GB / 57.8 GB 40.0 GB free
Help Sign in

admin / SAynapse-Horizon

public

Self Hosted Cyber Threat Intelligence Hub

Code Issues Pull requests Pipelines Packages Security Insights Wiki Settings
SAynapse-Horizon / Synapse-Horizon-v2 / src / api / client.js 927 B · main
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Thin client for the Synapse-Horizon ingestion service.
// Same-origin in production (nginx proxies /api → backend); the Vite dev server
// proxies /api during local development.
const BASE = import.meta.env.VITE_API_BASE || '/api'

async function req(path, opts) {
  const res = await fetch(`${BASE}${path}`, {
    headers: { 'Content-Type': 'application/json' },
    ...opts,
  })
  if (!res.ok) {
    let detail = ''
    try {
      detail = (await res.json())?.error || ''
    } catch {
      /* ignore */
    }
    throw new Error(detail || `Request failed (${res.status})`)
  }
  return res.json()
}

/** Current cached snapshot: { generatedAt, total, sources, iocs }. */
export const getFeeds = () => req('/feeds')

/** Trigger a live pull. Pass source keys to pull a subset; omit for all. */
export const syncFeeds = (sources) =>
  req('/sync', { method: 'POST', body: JSON.stringify(sources ? { sources } : {}) })