GithubHelp home page GithubHelp logo

todowebapp's Introduction

ToDoWebApp is a REST API that lets you add, manage and complete your own ToDos.

It was created as a learning experience for Spring and Hibernate. It's a backend app that should be 'consumed' by a frontend REST client eg. Angular JS. It supports basic CRUD operations via HTTP requests. Stack used:

  • Spring Boot
  • Spring Security for Basic Auth implementation and hashing passwords
  • Hibernate for ORM
  • H2 in-memory database to store registered users and their ToDos
  • JUnit & Mockito for unit and integration testing

Usage example:

POST @ localhost:8080/users with body:

{
	"username":"doublemc",
	"password":"password",
	"email":"[email protected]"
}

registers new user and responses with:

HTTP.Status: 201 Created 
{
  "status": "User created."
}

Then you can use POST @ localhost:8080/todos using JSON again to create a new ToDo:

{
	"title":"default",
	"dueDate": [
		2000,
		10,
		10
	]
}

...and the server response is: (id is autogenerated by database)

HTTP.Status 201 Created
{
  "id": 1, 
  "title": "default",
  "completed": false,
  "dueDate": [
    2000,
    10,
    10
  ]
}

After creating a ToDo you can view all your ToDos by using GET @ localhost:8080/todos :

[
  {
    "id": 1,
    "title": "default",
    "completed": false,
    "dueDate": [
      2000,
      10,
      10
    ]
  }
]

If you completed a ToDo just use PATCH @ localhost:8080/todos/{id}/complete (without any request body) and you will get HTTP.Status 200 OK.

Updating a ToDo can be achieved by using PUT @ localhost:8080/todos/{id} with the same JSON structure as in creating a new ToDo.

Removing a ToDo is easily achievable with DELETE @ localhost:8080/todos/{id} and server responses with HTTP.Status 204 No Content

If you don't like my API you can always delete your own account by using DELETE @ localhost:8080/users and it will delete from database currently logged in user (so called Principal in Spring Security).

All of the above requests (apart from creating a new user) require you to use Basic Authentication - provide username and password (that you used for account creation) to access those functionalities. If you don't use correct password or username is not found in the database you will get:

{
  "timestamp": 1487444087657,
  "status": 401,
  "error": "Unauthorized",
  "message": "Bad credentials",
  "path": "/todos/1"
}

todowebapp's People

Contributors

doublemc avatar

Stargazers

Jacek Musiał avatar

Forkers

bermateusz

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.