added project express routes
This commit is contained in:
@@ -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,
|
||||
}
|
||||
Reference in New Issue
Block a user