RealmDigital.Architecture 0.0.9

dotnet new install RealmDigital.Architecture::0.0.9                
This package contains a .NET Template Package you can call from the shell/command line.

The Realm Archicture - .NET Template

Installation

$ dotnet new install RealmDigital.Architecture

Usage

$ dotnet new realm-architecture -o [YOUR_PROJECT_NAME]

Use what you want, delete what you don't

Includes a fully featured application (.NET 7 Web API + Next.js UI)

Technology

  • .NET 7
  • EF Core 7
  • PostgreSQL
  • MediatR
  • Source Generators
  • Docker
  • NextJS
  • Identity
  • Terraform

Preamble

  1. Write a business operation as a MediatR Query/Command
[Authorize(Roles = nameof(Role.Admin))]
public sealed record GetUsersQuery : IQuery<List<CrudContracts.User>>
{
    public sealed class Handler : IQueryHandler<GetUsersQuery, List<CrudContracts.User>>
    {
        private readonly ApplicationContext _applicationContext;
        private readonly IMapper _mapper;

        public Handler(ApplicationContext applicationContext, IMapper mapper)
        {
            _applicationContext = applicationContext;
            _mapper = mapper;
        }

        public async Task<ErrorOr<List<CrudContracts.User>>> Handle(GetUsersQuery query, CancellationToken cancellationToken)
        {
            var users = await _applicationContext.Users.OrderByDescending(x => x.Id).ToListAsync(cancellationToken);
            return _mapper.Map<List<CrudContracts.User>>(users);
        }
    }
}
  1. Magic happens *

  2. Use the query/mutation in your React (or Vue) application

const getUsersQuery = UsersQueries.useGetUsersQuery()

if (getUsersQuery.isError) return <div>Failed to load</div>
if (getUsersQuery.isLoading) return <div>Loading...</div>

return (
    <ul>
    {users.map(user => (
        <li>{user.name}
    ))}
    </ul>
)
  1. Profit?!?!

* The magic is 3 parts

  1. Source generators automatically create Web API Controllers for each Query/Command - automatically, on build
  2. Nswag generates an OpenAPI specificiation document for these controllers - automatically, on build
  3. A .NET console application generates an Axios based TypeScript API client along with TanStack Query queries & mutations - manually, by running:
$ cd application/tools/[Application.Name].CodeGen.Console
$ dotnet run

This package has no dependencies.

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
0.0.9 203 6/27/2023
0.0.8 186 6/22/2023
0.0.7 161 6/21/2023
0.0.6 253 3/13/2023
0.0.5 258 3/6/2023
0.0.4 312 1/27/2023
0.0.3 333 1/20/2023
0.0.2 320 1/20/2023
0.0.1 313 12/5/2022