Skip to content

toiQS/Blog-Web-API

Repository files navigation

Blog Web API

Project Introduction

Blog-Web is an open source project that provides an API. The project leverages Entity Framework Core for database management, Identity Framework for user management and authentication, and JWT (JSON Web Token) for authentication and authorization.

Problem Statement

Developing a blog application involves several key challenges:

  1. Database Management: Efficient and secure storage and retrieval of information.
  2. User Management: User registration, login, and management.
  3. Authentication and Authorization: Ensuring valid users can access and perform specific actions within the system.
  4. Content Management: Effective creation, editing, and deletion of posts and comments.

Blog-Web Solution

Blog-Web addresses these challenges with the following approaches:

  1. Database Management with Entity Framework Core:

    • Provides an object-oriented approach to database interactions.
    • Simplifies the design, implementation, and maintenance of databases.
    • Supports multiple database management systems, streamlining development.
  2. User Management with Identity Framework:

    • Offers tools for user registration, login, multi-factor authentication, and role management.
    • Integrates with Entity Framework Core to efficiently store and manage user information.
  3. Authentication and Authorization with JWT:

    • Uses JSON Web Tokens for user authentication and session management.
    • Facilitates access control based on roles and encrypted information.
    • Reduces server load and improves performance for handling multiple sessions.
  4. Content Management:

    • Provides APIs for CRUD operations on posts and comments.
    • Enables flexible and effective content management for users.

The project is designed to be easily extensible and customizable, allowing developers to add features and integrate with other services as needed. Blog-Web provides a robust foundation for developing customized blog applications tailored to your needs.

I. Deployment

1. Set Up

Requirements:

  • Visual Studio 2017 or higher
  • SQL Server Management Studio (SSMS)
  • Postman

Steps:

  1. Update appsettings.json to replace {your name sql} with your SSMS instance name. image

  2. Open Package Manager Console in Visual Studio, set Default Project to Blog.Data. image

  3. If there are no existing migrations in Blog.Data:

    • Use add-migration {nameDb} or entityframeworkcore\add-migration {nameDb} to convert entities into tables. image

    • Run update-database to add tables to your SSMS. image

  4. If migrations already exist or there are no changes in entities, simply run update-database.

II. Run and Testing

1. Running the Application

Using Swagger

image

  • Press F5 to start the application. Swagger UI will open in the browser.
  • Interact with tasks that do not require authorization, such as GetAll.
  • For tasks that require authorization (e.g., CRUD operations), obtain authorization first. image

Using Postman

  • Use Postman for API testing and interaction. Ensure proper authorization where required.
  • After logging in through Swagger, obtain the token which is valid for 16 minutes.
  • To use the token in Postman:
    1. Copy the token from Swagger. image image

    2. In Postman, create a new request and enter the API endpoint URL.

    3. Go to the Authorization tab, select Bearer Token in the Type dropdown, and paste the token in the Token field. image

    4. Go to the Body tab, and select the appropriate body type (e.g., raw with JSON) for CRUD operations, if necessary. image

    5. Click Send to make the request. image

Libraries and Frameworks

  • Entity Framework Core
  • Identity Framework
  • Jwt Bearer
  • Asp.net

#akai #toiQS