Giter VIP home page Giter VIP logo

bookstoreapi's Introduction

BookStoreAPI

This is a bookstore or just a book api written in c# using asp.net core 6 core. THe goal of this project was to make an api, that returns books to anyone who calls it. It's also designed to be somewhat resistant to XSS attacks and has some rudimentary unit tests.

Most notable packages one should know:

-asp.net 6 core

-runs on port 9000 (http) and 9001 (https)

-https://localhost:9001/books/

-http://localhost:9000/books/

-c#

-AspNetCore.Identity.EntityFrameworkCore

-Microsoft.EntityFrameworkCore.Sqlite

-Microsoft.EntityFrameworkCore.Tools

-Newtonsoft

-HtmlSanitizer

Setting up

Clone the repository normally. After the cloning process is done, make sure that Books.db exists in the same folder as BookStoreAPI.

The Database

Database is hosted on Sqlite (in the file Books.db). So, make sure you have the file before booting the project. Make sure to run the following command on Package Manager Console: update-database or you might have to drop-database

The database will be set up during that process.

Folder categorisation

Starting from the top, we have controllers, that contains BooksController, which is reponsible for getting data.

Data folder contains datacontext and db migration files.

Middleware contains errorhandling and anti-Xss middleware.

Models houses three datamodels, Book, HttpResponseException, and PostRequestResponseMessage.

Utilities consists of two utility classes, HttpResponseUtilities and QueryUtilities. HttpResponseUtilities is used for throwing exceptions and AueryUtilities is used for depositing functions from BooksController to make it cleaner.

image

Booting up

After setting up the database, the initial startup will give you the swagger page. image

Responses containing books are sent back in Json.

BookStoreAPI.Tests

Things to know about .Tests:

-asp.net 6 core

-Fluent Assertions

-xUnit

-EntityFrameworkCore.InMemory

Database for tests

Database is held inside InMemory database. It doesn't need any setup to work. It's filled with dummy data. image

running tests

Tests can be run from the top bar as normal. The .Tests file should automatically a connection to BookStoreAPI solution. If all goes well, the tests should execute successfully.

bookstoreapi's People

Contributors

n0laja00 avatar

Stargazers

 avatar  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.