added project express routes

This commit is contained in:
Storme-bit
2026-04-13 06:12:18 -07:00
parent 07bd6a21ad
commit c14426ecaf
6 changed files with 118 additions and 1 deletions

View File

@@ -80,6 +80,38 @@ async function deleteSession(externalId) {
if (!res.ok) throw new Error(`Failed to delete session: ${res.status}`);
}
/******** PROJECTS ********* */
async function createProject({ name, description, colour, icon }) {
const res = await fetch(`${BASE_URL}/projects`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, description, colour, icon })
});
if (!res.ok) throw new Error(`Failed to create project: ${res.status}`);
return res.json();
}
async function getProjects() {
const res = await fetch(`${BASE_URL}/projects`);
if (!res.ok) throw new Error(`Failed to fetch projects: ${res.status}`);
return res.json();
}
async function updateProject(id, { name, description, colour, icon }) {
const res = await fetch(`${BASE_URL}/projects/${id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, description, colour, icon })
});
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
return res.json();
}
async function deleteProject(id) {
const res = await fetch(`${BASE_URL}/projects/${id}`, { method: 'DELETE' });
if (!res.ok) throw new Error(`Failed to delete project: ${res.status}`);
}
module.exports = {
getSessionByExternalId,
createSession,
@@ -90,4 +122,8 @@ module.exports = {
getSessions,
updateSession,
deleteSession,
createProject,
getProjects,
updateProject,
deleteProject,
}