Skip to content

Database API

Arjun Pratap edited this page Nov 8, 2023 · 1 revision

Current URL: https://devvy-web-server.onrender.com/

POST

/users

Creates a user

payload: {
    name: String,
    about: String,
    github: String,
    email: String
}

/users/:user_id/projects

Creates a project for user with ":user_id"

payload: {
    name: String
}

/projects/:project_id/tasks

Creates a Task in project with ":project_id"

payload: {
    title: String,
    deadline: String, // should follow iso 8601
    priority: "LOW" | "MEDIUM" | "HIGH",
    progress: "NOT_STARTED" | "IN_PROGRESS" | "COMPLETED"
}

}

/tasks/:task_id/subtasks

Creates a subtask in task with ":task_id"

payload: {
    text: String,
    is_completed: 0 | 1
}

GET

/root

Prints "Hello, World!"

/users

Get data of all users
informal type signature is something like

//get all users returns User[] where
type User = {
    id: Number
    name: String,
    about: String,
    github: String,
    email: String,
    projects: Project[]
}

// where
type Project = {
    id: Number,
    name: String,
    tasks: Task[]
}

//where
type Task = {
    title: String,
    deadline: String, // should follow iso 8601
    // iso 8601 is the following date format
    // YYYY-MM-DD
    priority: "LOW" | "MEDIUM" | "HIGH",
    progress: "NOT_STARTED" | "IN_PROGRESS" | "COMPLETED",
    subtasks: Subtask[]
}

//where
type SubTask = {
    id: Number,
    text: String,
    is_completed: 0 | 1
}

Example data

[
  {
    "id": 1,
    "name": "bar",
    "about": "random about",
    "github": "something",
    "email": "vasanthi@gmail.com",
    "projects": [
      {
        "id": 1,
        "name": "project 1",
        "tasks": [
          {
            "id": 1,
            "title": "perform first task",
            "deadline": "2023-11-05",
            "priority": "Low",
            "progress": "NotStarted",
            "subtasks": []
          },
          {
            "id": 2,
            "title": "do other task",
            "deadline": "2023-12-26",
            "priority": "High",
            "progress": "NotStarted",
            "subtasks": [
              {
                "id": 1,
                "text": "do the first sub task",
                "is_completed": false
              }
            ]
          }
        ]
      }
    ]
  },
  {
    "id": 2,
    "name": "Diwa",
    "about": "he's a dude",
    "github": "doesn't have one",
    "email": "diwatomy@gmail.",
    "projects": []
  }
]

/users/:user_id

Get data of user with particular user_id
same as get_all_users but returns a single User Instead of all users