Giter Site home page Giter Site logo

rest-service-java's Introduction

REST API (service)

Sample of REST service in Java.

Technologies:

  • Spring Boot
  • JPA, Spring Data, Pagination
  • Flyway DB migrations
  • Spring Security (API key auth)
  • Custom Exception handler
  • DTO, Validation

Setup

Clone repository

git clone https://github.com/dawidgorecki/rest-service-java.git

Run MySQL database

docker run -p 3307:3306 --name rest_service -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=rest_service -d mysql

Go inside folder and run application

cd rest-service-java

# on linux with maven wrapper
./mvnw clean install spring-boot:run

Authorization

API key passed in HTTP header.

Key: AUTH_API_KEY
Value: secret_key

API methods

Create task

POST http://localhost:8080/api/v1/tasks
{
    "name": "My task",
    "description": "Task description",
    "deadline": "2022-12-12"
}

Get all tasks

GET http://localhost:8080/api/v1/tasks

Get all with paging and sorting

GET http://localhost:8080/api/v1/tasks?page=0&size=2&sort=id,desc

Get one task with specified ID

GET http://localhost:8080/api/v1/tasks/5

Update task

PUT http://localhost:8080/api/v1/tasks/1
{
    "name": "My updated task",
    "description": "New description",
    "deadline": "2022-12-15"
}

Delete task

DELETE http://localhost:8080/api/v1/tasks/1

Mark as done

PATCH http://localhost:8080/api/v1/tasks/1

rest-service-java's People

Contributors

dawidgorecki avatar

Watchers

 avatar  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.