Giter VIP home page Giter VIP logo

aspnet.cqrs's Introduction

ASPNET.CQRS

Build RC NuGet Badge

Basic implementation of CQRS pattern for .NET Core web APIs.

Features

v1.0.0-rc2:

  • Bypass controllers and execute Queries and Commands directly
  • Supports simple (no params) and complex (with params) Queries and Commands
  • Automatically parses params - Queries uses query string and Commands uses request body (json)
  • Supports DI using default IServiceProvider

v1.0.0.-rc3:

  • Fire & forget command handlers

How to use?

  1. Get the lib package from nuget.org:
dotnet add package ASPNET.CQRS --version 1.0.0-rc2
  1. Then you need to setup the CQRSOptions in yours ConfigureServices method:
services.AddCQRS(options =>
{
    options.BasePath = "/api";
    options.Assemblies = new[] { Assembly.GetExecutingAssembly() };
});
  1. After that, in yours Startup's Configure method you need to configure CQRS's feature and CQRS's middleware:
app.UseCQRS();

The example configuration above will load queries and commands from the same assembly as yours Startup class.

  1. Once you have done the configuration, you can add your first query:
[CQRSRoute("/ping")]
public class PingQuery : IQueryHandler
{
    public Task Handle()
    {
        // noop
        return Task.CompletedTask;
    }
}
  1. And then test it with your favourite tool to test web APIs, cor example with cURL:
curl --request GET --url https://localhost:5001/api/ping

aspnet.cqrs's People

Contributors

wladyslawczyzewski avatar

Stargazers

 avatar Dominik Ruman avatar  avatar Vladyslav 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.