Skip to content

code-sparsh/blog-java-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlogPoint - Backend

About

This is a repo for the server application of BlogPoint, written in Java using Spring Boot

Built using

Java Spring MySQL

🛫 Quick Setup

# Clone the repo
git clone https://github.com/code-sparsh/blog-java-backend.git

# Navigate to the project directory
cd blog-java-backend

# Build the jar file
mvn clean package

# Execute the jar file
java -jar tar- GET/welcome-0.0.1-SNAPSHOT.jar

# (Optional) if skip test cases
java -jar tar- GET/welcome-0.0.1-SNAPSHOT.jar -DskipTests

📕 API Documentation


/api/auth: Authentication endpoints

- POST /login

Request:

{

   "email": "sparshsethi@example.com",
   "password": "1234@Abcd"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcGFyc2hzZXRoaUBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0Nzk0MiwiZXhwIjoxNzA0NzM0MzQyfQ.LuOkmhsOeYO4N754-v_Y1FEtXj5EwjGTjtG6SVeyGpg"
}

- POST /register

Request:

{
   "email": "sparshsethi@example.com",
   "password": "1234@Abcd",
   "name": "Sparsh Sethi"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcGFyc2hzZXRoaUBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0ODkwMCwiZXhwIjoxNzA0NzM1MzAwfQ.DAsBnh46abOB_dh3-_iqGaDo2G6a8aYa4ap_yvSSghs"
}
/api/blog: Blog endpoints

- GET / (get all Blogs)

Request Header:

{
     "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcGFyc2hzZXRoaUBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0Nzk0MiwiZXhwIjoxNzA0NzM0MzQyfQ.LuOkmhsOeYO4N754-v_Y1FEtXj5EwjGTjtG6SVeyGpg"
}

Response:

[
  {
      "id": "93f9d8a1-c612-44b5-8bee-9085cc076fee",
      "title": "Spring Boot Tutorial",
      "data": "Hi this is me, I am going to teach your Spring Boot today",
      "author": "Sparsh Sethi"
  },

  {
      "id": "fdc71a88-cd10-4fd5-8390-2c8d4f50001c",
      "title": "A test Blog",
      "data": "Welcome to the blog /n I am testing something here",
      "author": "Sparsh Sethi"
  }
]

- GET /{id} (get Blog by ID)

Request Header:

{
     "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcGFyc2hzZXRoaUBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0Nzk0MiwiZXhwIjoxNzA0NzM0MzQyfQ.LuOkmhsOeYO4N754-v_Y1FEtXj5EwjGTjtG6SVeyGpg"
}

Response:

{
  "id": "5f4c543e-817d-407d-af41-3567a36dc54d",
  "title": "A test Blog",
  "data": "Welcome to the blog /n I am testing something here",
  "author": "Sparsh Sethi"
}

- POST /create (Create a blog)

Request Header:

{
     "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzcGFyc2hzZXRoaUBleGFtcGxlLmNvbSIsImlhdCI6MTcwNDY0Nzk0MiwiZXhwIjoxNzA0NzM0MzQyfQ.LuOkmhsOeYO4N754-v_Y1FEtXj5EwjGTjtG6SVeyGpg"
}

Request Body:

{
   "title": "A test Blog",
   "data": "Welcome to the blog /n I am testing something here",
   "author": "Sparsh Sethi"
}

Response:

{
  "id": "299f230e-ee60-4d02-b440-9b83e993289d",
  "title": "A test Blog",
  "data": "Welcome to the blog /n I amhttps://icons8.com/icon/f34HG4w9RjQk/mysql testing something here",
  "author": "Sparsh Sethi"
}

About

Backend server for the BlogPoint project, built using Spring Boot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors