Skip to content

awaregroup/workshop-todo-backend

Repository files navigation

Todo Backend

Overview

This repo contains a semi-finished state of the project you will be working on in this workshop. You will be creating a new Spring Boot application and then leveraging GitHub Copilot to build out the code changes.

Pre-requisites

  1. Install GitHub Copilot extensions. If using Visual Studio Code, install both GitHub Copilot and GitHub Copilot Chat extensions. If using IntelliJ, install the GitHub Copilot extension.
  2. Log into the extension.
  3. Create a new (empty) Spring Boot application. If you're unable to create a new project, feel free to use the project in this repo, however you will need to delete the model, service and controller folders.

Backend high level steps

The following steps can be completed by writing prompts into GitHub Copilot. You'll see here we have the ability to author new code, generate business logic, refactor code and diagnose code. If you're encountering issues such as syntax errors or exceptions, remember you can use the /fix commands in GitHub Copilot to help diagnose the issue.

  1. Create a model package with a class called Todo. Generate the class with the following properties:
* Id (string)
* Title (string)
* Description (string)
* Completed (boolean)
  1. Without using GitHub Copilot, create a service package with an interface called ITodoService:
public interface ITodoService {
    List<Todo> getAllTodos();
    Todo getTodoById(String id);
    Todo createTodo(Todo todo);
    Todo updateTodo(String id, Todo todo);
    void deleteTodo(String id);
    void deleteTodoById(String id);
}
  1. Create an implementation of ITodoService called MemoryTodoService. Let all the implementation code be autogenerated. Make sure that the class is annotated with @Service for dependency injection.

  2. Create a REST controller using the route /api/todos and have it implement all the methods of ITodoService as CRUD operations. Make sure the constructor has been annotated with @Autowired so that the MemoryTodoService will be injected into the controller.

  3. Make sure there's a CORS policy allowing * on the REST controller.

Extra for experts

  1. Implement a health endpoint for the application to make sure the application is up and running.

  2. Add default http handler redirecting any non API/health routes to a 404. The only active handlers should be implemented on the API/health routes as this project is a REST API microservice only.

  3. Refactor the Todo class to incloude timestamps and deleted flag to the Todo items.

  4. Implement testing framework of choice. Include tests (and implementation updates) for the following:

  • Modify behaviour if required so the MemoryTodoService controls setting a new ID for each item. Do not allow upstream components to set the ID of the item being created.
  • Make sure on modification of Todo items, the ID cannot be changed.
  • Any other tests you find relevant.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages