Giter Site home page Giter Site logo

todo-app-back-end's Introduction

To Do App (Back End)

A basic API to control and save to dos. This is just the Back End.

NOTE: This does not have a database, but is made to make the change as painless as possible. See Implementing your own database for more information.

Try it yourself!

Currently the only way of trying the API is by running it locally. You need to have Java 17 and Maven installed on your computer. Follow the steps:

  1. Clone this repository.

    git clone https://github.com/Hisiste/ToDo-App-Back-End.git
    
  2. Enter the newly created folder.

    cd ./ToDo-App-Back-End
    
  3. Run the application.

    mvn spring-boot:run
    

    It'll run on http://localhost:9090/. See application.yml to change the port.

Goals

The program currently has/lacks the following functionality:

  • A GET endpoint (/todos) to list “to do’s”.
    • Include pagination. Pages should be of 10 elements.
  • Sort by priority and/or due date
  • Filter the list of "to do's".
    • By done or undone.
    • By the name or part of the name.
    • By priority.
  • A POST endpoint (/todos) to create “to do’s”
    • Validations included.
  • A PUT endpoint (/todos/{id}) to update the “to do” name, due date and/or priority.
    • Validations included.
  • A POST endpoint (/todos/{id}/done) to mark “to do” as done
    • This should update the “done date” property.
    • If “to do” is already done nothing should happen (no error returned).
  • A PUT endpoint (/todos/{id}/undone) to mark “to do” as undone.
    • If “to do” is already undone nothing should happen.
    • If “to do” is done, this should clear the done date.

How to use

Run the application first. Every to do will have the following information:

  • Integer id $\rightarrow$ An ID that defines the to do. Starts at 1.

  • String text $\rightarrow$ The name of the to do.

  • Date dueDate $\rightarrow$ The date and time the to do is due.

  • boolean done $\rightarrow$ If the to do is completed or not.

  • Date doneDate $\rightarrow$ When has the to do been completed.

  • Priority priority $\rightarrow$ The priority of the to do.

    enum Priority {
        Low, Medium, High
    }
  • Date creationDate $\rightarrow$ The date the to do was added.

API commands

TODO. Heh.

Implementing your own database

To add your database to this project, follow these steps:

  1. Add the corresponding dependency to pom.xml. Example using Postgresql:

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
  2. Add the following configuration to application.yml:

    spring:
        datasource:
            url: { your database url }
            username: { your database username }
            password: { your database password }
        jpa:
            hibernate:
                ddl-auto: create-drop
            properties:
                hibernate:
                    dialect: { Your database dialect }
                    format_sql: true
            show-sql: true

    The ddl-auto: create-drop WILL DESTROY the schema at the end of the session. Be careful and change if necessary.

  3. Uncomment code in ToDosRepository.java.

    // Uncomment this for using a database instead.
    public interface ToDosRepository extends JpaRepository<ToDos, Integer>{
        // Get to dos list filtered.
        public List<ToDos> findAllWithFilter(String name, String priority, String done) {
            // Use Queries to filter your to dos.
            return null;
        }
    }

    You can use JPA @Query to help you filter the to dos and finish the function.

  4. Comment code in ToDosRepository.java.

    // Comment ALL of this if using a database.
    import org.springframework.data.domain.Example;
    import org.springframework.data.domain.Page;
    import org.springframework.data.domain.Pageable;
    
    // ...
    
    public class ToDosRepository implements JpaRepository<ToDos, Integer> {
    
        // ...
    
        @Override
        public Page<ToDos> findAll(Pageable pageable) {
            return null;
        }
    }

    This is code used to define our to dos without a database. If you're implementing your own database, you don't need this code anymore.

Congratulations! This should be everything you need to do to set up and use your own database. :)

todo-app-back-end's People

Contributors

hisiste avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.