8000 GitHub - youngInnovator/Blog-RestAPI: Rest API using Spring Rest with Junit
[go: up one dir, main page]

Skip to content

youngInnovator/Blog-RestAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog - Rest API

Simple Restful CRUD API for Blog for POC or demo

Technologies used

  • Spring Boot
  • Spring Rest
  • Spring Data
  • MySQL database for persistent

Requirements

  1. Java - 1.8.x
  2. Maven - 3.x.x
  3. MySQL - 5.x.x

Steps to Setup

1. Clone the application

  • clone this project into your local directory: git clone https://github.com/youngInnovator/Blog-RestAPI.git

2. Create MySQL database

In order to achieve persistence this project relies on MySQL.

MySQL version 5.6 or better. If you have Docker installed it might be useful to run the database as a container.

Create the database for MySQL using following steps.

mysql> create database db_blog; -- Create the new database
mysql> create user 'blog'@'localhost' identified by 'blog'; -- Creates the user
mysql> grant all on db_example.* to 'blog'@'localhost'; -- Gives all the privileges to the new user on the newly created database

3. Change MySQL username and password as per your installation

  • open src/main/resources/application.properties
  • change spring.datasource.username and spring.datasource.password as per your MySQL installation (if required)

4. Build and run the app using maven

  • Build the project:
mvn clean install
  • Run the blog project:
java -jar blog-0.0.1-SNAPSHOT.jar

Alternatively, you can run the app without packaging it using -

mvn spring-boot:run

The app will start running at http://localhost:8080.

Run unit test

mvn test

Explore Rest APIs

The app defines following CRUD APIs.

  1. Get all posts
GET /blog/post/
  1. Get specific post
GET /blog/post/{postId}
  1. Add new post
POST /blog/post/
  1. Update existing post
PUT /blog/post/
  1. Delete specific post
DELETE /blog/post/{postId}
  1. Get specific post comments
GET /blog/post/{postId}/comments
  1. Add new comment to specific post
POST /blog/post/{postId}/comment
  1. Get specific comment
GET /blog/comment/{commentId}
  1. Like specific comment
POST /blog/comment/{commentId}/like
  1. Update existing comment
PUT /blog/comment/
  1. Delete specific comment
DELETE /blog/comment/{postId}

About

Rest API using Spring Rest with Junit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0