A backend API for todo application.
Tech Stack: NodeJS, PostgreSQL.
It supports following features:
- The user can create/read/update/delete todos.
- The user can search an existing todo by title/date/priority/state
- The user can prioritize the todos
- Send a GET request to
localhost:3000/todos
to see all the todos. - Send a POST request to
localhost:3000/todos
to CREATE a todo. - Send a GET request to
localhost:3000/todos/id/:id
to READ a todo by the ID. - Send a PUT request to
localhost:3000/todos/id/:id
to UPDATE a todo (description and priority). - Send a PUT request to
localhost:3000/todos/:title/complete
to UPDATE a todo to mark complete by the Title. - Send a DELETE request to
localhost:3000/todos/id/:id
to DELETE a todo by the ID.
- Send a GET request to
localhost:3000/todos/:title
to Search by Title. - Send a GET request to
localhost:3000/todos/priority/:priority
to Search by priority. - Send a GET request to
localhost:3000/todos/top/priority
to find the top priority todo. - Send a GET request to
localhost:3000/todos/search/date
to Search by Date. - Send a GET request to
localhost:3000/todos/search/incomplete
to Search all Incomplete todos. - Send a GET request to
localhost:3000/todos/search/complete
to Search all Complete todos.
The schema for todo looks like this
todo {
id, // integer, primary key
title, // string
description, // string
isCompleted, // boolean
priority, // integer
date // date
}
- while creating a todo user can provide title, description and priority.
- Priority is optional, the default priority is 1.
- date is the date of creation.
- date is assumed to be the date for todo to be done.
- Priority increases with the number.
- Different todos can have same priority.
- Title of the todo must be unique.
- Clone the repo and do
npm install
to load the node modules. - Should have Postgresql in your system, then create a user, it's password and database.
- Enter the credentials in
server.js
andmodels\toDoItem.js
files. - Uncomment line no 42 in
todoItem.js
. - Hit
node server.js
to run. - Comment line no 42 in
todoItem.js
. - The app will run on
localhost:3000/
**I took reference from this article for PostgreSQL: Link