This is a fully CRUD RESTful API that allows users to manage their user account and tasks
- utilizes progreSQL as the database to store user and tasks information
-
- run
brew install mvn
- run
- PgAdmin4 (Optional)
./spin_up_postgres.sh
./mvnw spring-boot:run
- right click on Servers on left side.
- Register -> Server
- Name: todo_list
- click on Connection tab
- Host name/address: localhost
- port: 5455
- Username: postgrewuser
- Password: postgrespw
private Long id; // Auto generated
private String name;
private String email;
@OneToMany
private List<Task> tasks = new ArrayList<>();
private Timestamp createdAt; // Auto generated
private Timestamp updatedAt; // Auto generated
private Long id; // Auto generated
private String title;
@ManyToOne
private User user;
private OffsetDateTime dueDate;
private Timestamp createdAt; // Auto generated on creation
private Timestamp updatedAt; // Auto generated on update
by default base URL is http://localhost:8080
/user
- Returns a list of users and all their associated data.
example return:
[
{
"id": 1,
"name": "Bob",
"email": "bob@example.com",
"tasks": [
{
"id": 1,
"title": "Take out trash",
"dueDate": "2023-04-10T19:00:00-05:00",
"createdAt": "2023-03-23T19:25:55.170+00:00",
"updatedAt": "2023-03-23T19:25:55.170+00:00"
}
],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
},
{
"id": 2,
"name": "Bill",
"email": "bill@example.com",
"tasks": [],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
},
{
"id": 3,
"name": "Mickey",
"email": "mickey@example.com",
"tasks": [],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
}
]
/user/{user_id}
- Returns all data associated with that user
example return:
{
"id": 4,
"name": "Mickey Mouse",
"email": "mickey@example.com",
"tasks": [
{
"id": 1,
"title": "Take out trash",
"dueDate": "2023-04-10T19:00:00-05:00",
"createdAt": "2023-03-23T19:25:55.170+00:00",
"updatedAt": "2023-03-23T19:25:55.170+00:00"
}
],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
}
/user
- Returns: the created user
example Body:
{
"name": "Mickey Mouse",
"email": "mickey@example.com"
}
example return:
{
"id": 4,
"name": "Bruce",
"email": "bruce@example.com",
"tasks": [],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
}
/user/{id}
- Returns: the edited user object
example Body:
{
"name": "Mickey Mouse",
"email": "mickey@example.com"
}
example return:
{
"id": 4,
"name": "Mickey Mouse",
"email": "mickey@example.com",
"tasks": [],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
}
/user/{user_id}/task/add
- Returns: User task got added to.
example Body:
{
"title": "Take out trash",
"dueDate": "2023-04-10T19:00:00-05:00"
}
example Return:
{
"id": 1,
"name": "Bob",
"email": "bob@example.com",
"tasks": [
{
"id": 1,
"title": "Take out trash",
"dueDate": "2023-04-10T19:00:00-05:00",
"createdAt": "2023-03-23T19:25:55.170+00:00",
"updatedAt": "2023-03-23T19:25:55.170+00:00"
}
],
"createdAt": "2023-03-23T19:29:05.770+00:00",
"updatedAt": "2023-03-23T19:29:05.770+00:00"
}
/user/{user_id}
example return:
User with id 4 successfully deleted
/task
- Returns a list of tasks and all their associated data.
example return:
[
{
"id": 1,
"title": "Take out trash",
"dueDate": "2023-04-10T19:00:00-05:00",
"createdAt": "2023-03-23T19:41:46.675+00:00",
"updatedAt": "2023-03-23T19:41:46.675+00:00"
},
{
"id": 2,
"title": "Read 2 hours",
"dueDate": "2023-05-10T19:00:00-05:00",
"createdAt": "2023-03-23T19:41:46.678+00:00",
"updatedAt": "2023-03-23T19:41:46.678+00:00"
},
{
"id": 3,
"title": "Complete homework 1-5",
"dueDate": "2023-04-01T19:00:00-05:00",
"createdAt": "2023-03-23T19:41:46.679+00:00",
"updatedAt": "2023-03-23T19:41:46.679+00:00"
},
{
"id": 4,
"title": "Do dishes",
"dueDate": "2023-06-17T19:00:00-05:00",
"createdAt": "2023-03-23T19:41:46.681+00:00",
"updatedAt": "2023-03-23T19:41:46.681+00:00"
}
]
/task/{task_id}
- Returns all data associated with the task
example return:
{
"id": 4,
"title": "Do dishes",
"dueDate": "2023-06-17T19:00:00-05:00",
"createdAt": "2023-03-23T19:41:46.681+00:00",
"updatedAt": "2023-03-23T19:41:46.681+00:00"
}
/task/{id}
- Returns: the edited task object
example Body:
{
"title": "Pick up groceries",
"dueDate": "2023-03-23T00:00:00+00:00"
}
example return:
{
"id": 2,
"title": "Pick up groceries",
"dueDate": "2023-03-23T00:00:00Z",
"createdAt": "2023-03-23T19:41:46.678+00:00",
"updatedAt": "2023-03-23T19:42:42.950+00:00"
}
/task/{id}
example return:
Task with id 4 successfully deleted