Skip to content

HaoLiangPao/BlogBackend-Dagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 

Repository files navigation

Backend for Six Degrees of Kevin Bacon

Keywords: Java backend, NoSQL (Neo4j), REST API, Maven

1. Descriptions

This is an Java implementation of the backend for a service that allows users to post, view and delete blog posts. Dependency injection was done through Dagger. REST-api was used for server communication.

  • The backend is running on port 8080.
  • MongoDB database is called as blogs;
  • Collections called posts;

2. Project/IDE Setup

  • Command Line:
    • Install maven
    • To compile your code simply run mvn compile in the root directory (the folder that has pom.xml)
    • To run your code run mvn exec:java
  • Eclipse:
    • File → Import → Maven → Existing Maven Projects
    • Navigate to the project location
    • Right click the project → Maven Build…
    • Input compile exec:java in the Goals input box
    • Click apply then run/close
    • You can now run the project by pressing the green play button
  • Intellij:
    • Import project
    • Navigate to the project location
    • Import project from external model → Maven
    • Next → Next → Next → Finish
    • Add Configuration → + Button → Maven
    • Name the configuration and input exec:java in the Command Line box
    • Apply → Ok
    • You can now run the project by pressing the green play button

3. Testing

  • Response Body:

    • JSON format
  • Response Status:

    • 200 OK for successful delete
    • 400 BAD REQUEST if the request body is improperly formatted or missing required information
    • 500 INTERNAL SERVER ERROR if save or add was unsuccessful (if user has done everything as per requirements but request is unable to respond correctly)
    • 404 NOT FOUND if post does not exist
    • 405 METHOD NOT ALLOWED if called with something other than GET, PUT, DELETE
  • Existing endpoints:

    • (GET) http://localhost:8080/api/v1/post
      • Get blog post. Returns list of corresponding posts. If _id is specified, return the exact post that has that _id. If title is specified, return all posts that contain the specified words in the given title, in order.
      • Request Body:
        {
             "title": "First"
        }
        or
        {
             "_id": "3m4jk393jneke93h3k"
        }
        or
        {
             "title": "First"
             "_id": "3m4jk393jneke93h3k"
        }
    • (PUT) http://localhost:8080/api/v1/post
      • Request Body:
        {
             "title": "My First Post",
             "author": "Jake Peralta",
             "content": "This is my first post. I’m very excited to create this blog. YAY!",
             "tags": [
                 "first post",
                 "new blog",
                 "excitement"
             ]
        }
    • (DELETE) http://localhost:8080/api/v1/post
      • Request Body:
        {
             "_id": "3m4jk393jneke93h3k"
        }
  • PostMan Testing Package: You can download it from the PostMan folder.

About

A simple backend for blog service with Dagger for dependency injection and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages