zanio / library-spring

This is a book api library built with spring boot. The response of the api follows the HATEOS principle. you can create books, add category, delete book, add book to category, mark one or more book as favorite.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting Started

Reference Documentation

This is a project to demonstrate RESTful API with spring boot . The task is to build a book library. you can find the hosted documentation @ BookApi

Feature Requirements

The list of required features are as follows:

  • Add Category
  • Edit Category
  • List Categories
  • Add Book
  • Edit Book
  • List Books
  • Add Books to category

Others:

  • Create list of favorite books
  • Delete Category/Book
  • API documentation

DEVELOPMENT

Database setup

TO CREATE A DATABASE, USER AND GRANT ALL PRIVILEGE TO THAT USER ON THE CREATED DATABASE RUN THE FOLLOWING CODE:

If you are just setting up your environment then Run The below code on the project root directory of the application--

export PGPASSWORD='<root-postgres-db-password>'; psql -h localhost -p 5432 -U <root-user> -f initializer.sql -d <root-database>

for example you can type this:

export PGPASSWORD='password1234'; psql -h localhost -p 5432 -U postgres -f initializer.sql -d postgres

Where <root-postgres-db-password> is the root password of postgres You should set multiple database, i.e for test and dev. The test environment would handle integration testing All you have to is to edit the initialize.sql with your own database name, database password and database username .

ENVIRONMENT VARIABLE.

other required environment variables can be gotten from the env.example file.

Starting up the application:

make sure you resolve all dependencies first. To start the application based on intellij you can just use the play button on intellij. OR You can just compile and start the application from the command line while on the app directory using the following command

  • mvn clean install

and start the application using the following command:

  • java -jar target/Library-0.0.1-SNAPSHOT.jar

note: make sure you set all required environment variables as required by the env.example file using the command if on linux export KEY="value"

Testing up the application:

  • from intellij you can run the test files individually or within each folder.

About

This is a book api library built with spring boot. The response of the api follows the HATEOS principle. you can create books, add category, delete book, add book to category, mark one or more book as favorite.

License:MIT License


Languages

Language:Java 100.0%