Giter Club home page Giter Club logo

todos-api's Introduction

Todos Backing API

A sample Spring Boot app that implement a Todo API.

Todos API works with this UI but can be used by itself. If you're interested in running this app as a backend to the UI then start with this repo.

Domain and core API

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    class Todo implements Serializable {
        private String id;
        private String title;
        private Boolean completed = Boolean.FALSE;
    }
    @PostMapping("/")
    public Todo create(@RequestBody Todo todo) { }
    @GetMapping("/{id}")
    public Todo retrieve(@PathVariable String id) { }
    @PatchMapping("/{id}")
    public Todo update(@PathVariable String id, @RequestBody Todo todo) { }
    @DeleteMapping("/{id}")
    public void delete(@PathVariable String id) { }

Build

This project was created from the Spring Initialzr as a Java 1.8, Maven build project. You can build locally using the maven wrapper (mvnw).

Tomcat is default

./mvnw clean package
# target/todos-api-1.0.0.SNAP.jar

Build with Jetty

./mvnw clean package -P jetty
# target/todos-api-1.0.0.SNAP.jar

Build with Undertow

./mvnw clean package -P undertow
# target/todos-api-1.0.0.SNAP.jar

Run on PCF

  1. Consider forking this project then clone to dev machine
  2. cd into project
  3. mvnw clean package
  4. modify manifest.yml for your cloudfoundry tastes (custom route perhaps?)
  5. login to PCF (or PWS)
  6. cf push (awwwweee yeah)

Local

You can clone, build, run then access localhost:8080 or change the port.

java -jar ./target/todos-api-1.0.0.SNAP.jar \
  --server.port=whatever

Run with Remote Debug

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=9111,suspend=n \
  -jar target/todos-api-1.0.0.SNAP.jar

Todo(s) Properties

TodosProperties contains a couple application properties.

# limit number of todos to put in map
todos.api.limit=1024
# use 8 char random string for id or 36 (uuid)
todos.ids.tiny-id=true

Verify

Once Todo(s) API is running access it directly using cURL or HTTPie to perform CRUD operations.

> http :8080/ title="make bacon pancakes"
HTTP/1.1 200  
Content-Type: application/json;charset=UTF-8

{
    "completed": false,
    "id": "c81d4e2e",
    "title": "make bacon pancakes"
}

Spring Boot references:

  1. Dependency Management in Spring Boot - exact dependency versions
  2. Spring Boot Dependencies
  3. Spring Boot Starters - this app uses spring-boot-starter-web, spring-boot-starter-actuator and spring-boot-starter-sleuth
  4. How to embed Web Servers - for servlet stack web apps use tomcat, jetty, or undertow. For reactive stack web apps use the previous servers or netty.
  5. Spring Boot Auto Configuration - @SpringBootApplication or @EnableAutoConfiguration
  6. Externalized Configuration
  7. ConfigurationProperties
  8. @ConfigurationProperties vs @Value
  9. Spring MVC Auto-configuration
  10. Spring Boot Security
  11. Testing Spring Boot Applications
  12. Actuator Endpoints

todos-api's People

Contributors

corbsmartin avatar corbtastik avatar

Watchers

 avatar

Forkers

pgottam

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.