const BASE = "http://localhost:5174/stream";

export const fetchStreams = () =>
  fetch(`${BASE}`).then((r) => r.json());

export const fetchStream = (id) => fetch(`${BASE}/${id}`).then((r) => r.json());

export const createStream = (s) =>
  fetch(BASE, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(s),
  }).then((r) => r.json());

export const updateStream = (id, s) =>
  fetch(`${BASE}/${id}`, {
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(s),
  }).then((r) => r.json());

export const deleteStream = (id) => fetch(`${BASE}/${id}`, { method: "DELETE" });
