Node.js + Express 5 backend with flat NDJSON key-value store (borrowed from electronics-inventory). Sequential integer IDs per namespace. Vanilla JS SPA with filters for status, priority, and tags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
17 lines
666 B
JavaScript
17 lines
666 B
JavaScript
async function req(method, path, body) {
|
|
const opts = { method, headers: {} };
|
|
if (body !== undefined) {
|
|
opts.headers['Content-Type'] = 'application/json';
|
|
opts.body = JSON.stringify(body);
|
|
}
|
|
const res = await fetch(path, opts);
|
|
const data = await res.json();
|
|
if (!data.ok) { throw new Error(data.error ?? 'Request failed'); }
|
|
return data;
|
|
}
|
|
|
|
export const get_tasks = () => req('GET', '/api/tasks');
|
|
export const create_task = (body) => req('POST', '/api/tasks', body);
|
|
export const update_task = (id, body) => req('PUT', `/api/tasks/${id}`, body);
|
|
export const delete_task = (id) => req('DELETE', `/api/tasks/${id}`);
|