Giter VIP home page Giter VIP logo

bookapi's Introduction

Simple Library CRUD API Documentation

Welcome to the Simple Library CRUD API documentation application. This API allows restful operations on Books, Authors & Publisher Information.

Table of Contents

Getting Started

Prerequisites

Before you start, make sure you have the following prerequisites installed on your system:

  • Dotnet Sdk (>= 8.0)
  • RabbitMQ
  • Redis
  • Database (e.g., MSSQL) or Cloud MSSQL. In this project, Cloud SQL Server database was used

Installation

  1. Clone this repository: Open a terminal and run

    git clone https://github.com/7j4n1/BookApi.git
    cd BookApi 
  2. Install the dotnet packages for the project in the project by running:

    dotnet build
  3. Configure your application settings in the appsettings.json:

    cp appsettings.Development.json appsettings.json

    Configure the database, redis and rabbitmq config variables as follows:

    "AllowedHosts": "*",
    "RedisCloudUrl": "redis-hostname:port,password=your-password",
    "RabbitMqUrl": "your-rabbitmqsetting-endpoint-goes-here",
    "ConnectionStrings": {
        "DefaultConnection" : "Data Source=mssql-servername;Initial Catalog=database-name;User ID=username;Password=password;TrustServerCertificate=true;"
    }
  4. Ensure that you've started them 3 servers (Redis, SQL Server, RabbitMQ)

  5. Run the migrations:

    dotnet build
    
    dotnet-ef migrations add "Migration Name"
    
    dotnet-ef database update  - to update the database with the Api Models
  6. Start the development server:

    dotnet run | dotnet run --launch-profile https (To force run on https scheme)
    

    BookApi API is now up and running on {https://localhost:7057} which is the base url!

  7. Open a browser and navigate to https://localhost:7057/swagger to see an API documentation

API Endpoints

Request and Response Formats

The API uses JSON for both requests and responses. The following table describes the JSON format for the requests and responses:

Books

Requests Response
POST /api/v1/Books 201 Created with the newly created book in the response body
GET /api/v1/Books 200 OK with an array of Books in the response body.
GET /api/v1/Books/{id} 200 OK with the book with the specified id in the response body.
PUT /api/v1/Books/{id} 200 OK with the updated book in the response body.
DELETE /api/v1/Books/{id} 204 No Content
### Author
Requests Response
POST /api/v1/Authors 201 Created with the newly created author in the response body
GET /api/v1/Authors 200 OK with an array of Authors in the response body.
GET /api/v1/Authors/{id} 200 OK with the author with the specified id in the response body.
PUT /api/v1/Authors/{id} 200 OK with the updated author in the response body.
DELETE /api/v1/Authors/{id} 204 No Content
### Publisher
Requests Response
POST /api/v1/Publishers 201 Created with the newly created publisher in the response body
GET /api/v1/Publishers 200 OK with an array of Publishers in the response body.
GET /api/v1/Publishers/{id} 200 OK with the publisher with the specified id in the response body.
PUT /api/v1/Publishers/{id} 204 OK with no content
DELETE /api/v1/Publishers/{id} 204 No Content

Notification

Requests Response
GET /api/v1/Notification 200 OK with a single notification fetched from the Queue Consumer in the response body.

Note

Once a new Book is uploaded from the /Books enpoint, The RabbitMQ Producer publish the new book info and a message "New book has been published" to the Queue and the Notification enpoint uses an async Class Method to get consume the message from the queue through the route "new_book".

And if no new Book published, the Nofitication return "No new book published"

Sample Usage

No Nofication available

No New Notification

Adding a new Book (201 Created)

Create new Book

Response new Book

The details of the new Book posted

New Notification

Fetch the details of a author (200 OK)

fetch the details of a author

Modify the details of an existing publisher (204)

modify the details of an existing publisher

modify the details of an existing publisher

RabbitMQ Management Dashboard

RabbitMQ

License

The MIT License (MIT)

bookapi's People

Contributors

7j4n1 avatar

Watchers

 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.