Skip to content

hackpacific/to_do_list_full_stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To Do List Full-stack

This is a To Do list full-stack application. It has a user table and a task table. And a front-end that consumes the API.

API endpoints

Before you start, create a new user account by sending a post request to '/users'. It will return an object like this:

{ success: true, id: 1 }

The id will be your api_key for making requests to the following tasks endpoints.

Tasks

URI Type Description Request Body Sample Response
api/tasks?api_key=your_user_id GET Returns an object with a tasks property that contains an array of tasks belonging to you. N/A
{
  tasks: [
    { id: 1,
      content: 'A to do list task',
      complete: 'false',
      due: datetime,
      updated_at: datetime,
      created_at: datetime
    },
    { id: 2,
      content: 'Another to do list task',
      complete: 'true',
      due: datetime,
      updated_at: datetime,
      created_at: datetime
    },
  ]
}
api/tasks?api_key=your_user_id POST Creates a new task under your user account.
{
  task: {
    content: 'This is a task',
    due: 'Sat Oct 21 2017
    14:05:00 GMT+0800 (HKT)'
  }
}
{
  task: {
    id: 1,
    content: 'This is a task',
    complete: 'false',
    due: '2017-10-21T06:01:02.000Z',
    created_at: '2017-10-21T06:00:07.065Z'
  }
}
api/tasks/:id?api_key=your_user_id PUT Update the content or due time of the task specified by id.
{
  task: {
    content: 'This is not a task',
    due: 'Sat Oct 21 2017
    14:09:38 GMT+0800 (HKT)',
  }
}
{
  task: {
    id: 1,
    content: 'This is not a task',
    complete: 'true',
    due: '2017-10-21T06:09:38.000Z',
    created_at: '2017-10-21T06:00:07.065Z',
    updated_at: '2017-10-21T06:09:54.730Z'
  }
}
api/tasks/:id/mark_complete?api_key=your_user_id PUT Mark the complete property to true for the task specified by id. N/A
{
  task: {
    id: 1,
    content: 'This is a task',
    complete: 'true',
    due: datetime,
    created_at: DateObject,
    updated_at: DateObject
  }
}
api/tasks/:id/mark_active?api_key=your_user_id PUT Mark the complete property to false for the task specified by id. N/A
{
  task: {
    id: 1,
    content: 'This is a task',
    complete: 'false',
    due: datetime,
    created_at: DateObject,
    updated_at: DateObject
  }
}
api/tasks/:id?api_key=your_user_id DELETE Delete the task specified by id. N/A
{
  success: true
}

Datetime

Datetime objects are stored in UTC time.

Front-end App

The To Do List front-end is located at root /. It uses the user id 1 to make requests.

Running the server locally

After downloading the repository Install the gems

bundle

Create the database

rails db:create

Migrate the database

rails db:migrate

Seed the database

rails db:seed

Start server:

rails s

Visit localhost:3000 to see the To Do List.