HopFrame.Api 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package HopFrame.Api --version 1.1.0                
NuGet\Install-Package HopFrame.Api -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HopFrame.Api" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HopFrame.Api --version 1.1.0                
#r "nuget: HopFrame.Api, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HopFrame.Api as a Cake Addin
#addin nuget:?package=HopFrame.Api&version=1.1.0

// Install HopFrame.Api as a Cake Tool
#tool nuget:?package=HopFrame.Api&version=1.1.0                

HopFrame API module

This module contains some useful endpoints for user login / register management.

Ho to use the Web API version

  1. Add the HopFrame.Api library to your project:

    dotnet add package HopFrame.Api
    
  2. Create a DbContext that inherits the HopDbContext and add a data source

    public class DatabaseContext : HopDbContextBase {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
            base.OnConfiguring(optionsBuilder);
    
            optionsBuilder.UseSqlite("...");
        }
    }
    
  3. Add the DbContext and HopFrame to your services

    builder.Services.AddDbContext<DatabaseContext>();
    builder.Services.AddHopFrame<DatabaseContext>();
    

Endpoints

By default, the module provides a controller for handling authentication based requests by the user. You can explore the contoller by the build in swagger site from ASP .NET.

Disable the Endpoints

builder.Services.AddDbContext<DatabaseContext>();
//builder.Services.AddHopFrame<DatabaseContext>();
services.AddHopFrameNoEndpoints<TDbContext>();

Services added in this module

You can use these services by specifying them as a dependency. All of them are scoped dependencies.

LogicResult

Logic result is an extension of the ActionResult for an ApiController. It provides simple Http status results with either a message or data by specifying the generic type.

public class LogicResult : ILogicResult {
    public static LogicResult Ok();

    public static LogicResult BadRequest();

    public static LogicResult BadRequest(string message);

    public static LogicResult Forbidden();

    public static LogicResult Forbidden(string message);

    public static LogicResult NotFound();

    public static LogicResult NotFound(string message);

    public static LogicResult Conflict();

    public static LogicResult Conflict(string message);

    public static LogicResult Forward(LogicResult result);

    public static LogicResult Forward<T>(ILogicResult<T> result);

    public static implicit operator ActionResult(LogicResult v);
}

public class LogicResult<T> : ILogicResult<T> {
    public static LogicResult<T> Ok();

    public static LogicResult<T> Ok(T result);
    
    ...
}

IAuthLogic

This service handles all logic needed to provide the authentication endpoints by using the LogicResults.

public interface IAuthLogic {
    Task<LogicResult<SingleValueResult<string>>> Login(UserLogin login);

    Task<LogicResult<SingleValueResult<string>>> Register(UserRegister register);

    Task<LogicResult<SingleValueResult<string>>> Authenticate();

    Task<LogicResult> Logout();

    Task<LogicResult> Delete(UserPasswordValidation validation);
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 76 11/23/2024
1.1.0 103 9/26/2024
1.0.0 85 8/4/2024