📘 API Reference

Below is a reference for all the key API routes used in the TaskFlow project. All requests are handled through Supabase and secured with role-based policies.

📌 Tasks API

GET /tasks – Fetch all tasks

Returns a list of all tasks for the authenticated user.

const { data, error } = await supabase.from("tasks").select("*")

POST /tasks – Create a new task

Insert a new task into the database.

const { data, error } = await supabase.from("tasks").insert([{ title: "New Task", status: "todo" }])

PATCH /tasks/:id – Update a task

const { data, error } = await supabase.from("tasks").update({ status: "done" }).eq("id", taskId)

DELETE /tasks/:id – Delete a task

const { data, error } = await supabase.from("tasks").delete().eq("id", taskId)

📁 Projects API

GET /projects – Fetch all projects

const { data, error } = await supabase.from("projects").select("*")

POST /projects – Create a new project

const { data, error } = await supabase.from("projects").insert([{ name: "New Project" }])

🔐 Auth API

POST /auth/sign-in – Sign in a user

const { data, error } = await supabase.auth.signInWithPassword({ email, password })

POST /auth/sign-up – Register a new user

const { data, error } = await supabase.auth.signUp({ email, password })

POST /auth/sign-out – Sign out the current user

const { error } = await supabase.auth.signOut()

🔒 All endpoints are protected using Supabase Row-Level Security (RLS) policies based on the authenticated user's ID.