Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 2e623e9

Browse files
committed
beta testing
1 parent 71d7a6a commit 2e623e9

26 files changed

Lines changed: 417 additions & 65 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Threading.Tasks;
2+
using Jp.Domain.Core.Bus;
3+
using Jp.Domain.Core.Commands;
4+
using Jp.Domain.Core.Events;
5+
using Jp.Domain.Core.Notifications;
6+
using MediatR;
7+
8+
namespace Jp.Application.Bus
9+
{
10+
public sealed class InMemoryBus : IMediatorHandler
11+
{
12+
private readonly IMediator _mediator;
13+
private readonly IEventStore _eventStore;
14+
15+
public InMemoryBus(IMediator mediator, IEventStore eventStore)
16+
{
17+
_mediator = mediator;
18+
_eventStore = eventStore;
19+
}
20+
21+
public Task<bool> SendCommand<T>(T command) where T : Command
22+
{
23+
return _mediator.Send<bool>(command);
24+
}
25+
26+
public async Task RaiseEvent<T>(T @event) where T : Event
27+
{
28+
if (!@event.MessageType.Equals(nameof(DomainNotification)))
29+
await _eventStore.Save(@event);
30+
31+
await _mediator.Publish(@event);
32+
}
33+
}
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Jp.Application.Interfaces;
2+
using Jp.Application.Services;
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace Jp.Application.Configuration
6+
{
7+
internal class ApplicationBootStrapper
8+
{
9+
public static void RegisterServices(IServiceCollection services)
10+
{
11+
services.AddScoped<IPersistedGrantAppService, PersistedGrantAppService>();
12+
services.AddScoped<IApiResourceAppService, ApiResourceAppService>();
13+
services.AddScoped<IIdentityResourceAppService, IdentityResourceAppService>();
14+
services.AddScoped<IScopesAppService, ScopesAppService>();
15+
services.AddScoped<IClientAppService, ClientAppService>();
16+
}
17+
}
18+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Jp.Domain.CommandHandlers;
2+
using Jp.Domain.Commands.ApiResource;
3+
using Jp.Domain.Commands.Clients;
4+
using Jp.Domain.Commands.IdentityResource;
5+
using Jp.Domain.Commands.PersistedGrant;
6+
using MediatR;
7+
using Microsoft.Extensions.DependencyInjection;
8+
9+
namespace Jp.Application.Configuration
10+
{
11+
internal class DomainCommandsBootStrapper
12+
{
13+
public static void RegisterServices(IServiceCollection services)
14+
{
15+
services.AddScoped<IRequestHandler<RemovePersistedGrantCommand, bool>, PersistedGrantCommandHandler>();
16+
17+
/*
18+
* Api Resource commands
19+
*/
20+
services.AddScoped<IRequestHandler<RegisterApiResourceCommand, bool>, ApiResourceCommandHandler>();
21+
services.AddScoped<IRequestHandler<UpdateApiResourceCommand, bool>, ApiResourceCommandHandler>();
22+
services.AddScoped<IRequestHandler<RemoveApiResourceCommand, bool>, ApiResourceCommandHandler>();
23+
services.AddScoped<IRequestHandler<RemoveApiSecretCommand, bool>, ApiResourceCommandHandler>();
24+
services.AddScoped<IRequestHandler<SaveApiSecretCommand, bool>, ApiResourceCommandHandler>();
25+
services.AddScoped<IRequestHandler<RemoveApiScopeCommand, bool>, ApiResourceCommandHandler>();
26+
services.AddScoped<IRequestHandler<SaveApiScopeCommand, bool>, ApiResourceCommandHandler>();
27+
28+
/*
29+
* Identity Resource commands
30+
*/
31+
services.AddScoped<IRequestHandler<RegisterIdentityResourceCommand, bool>, IdentityResourceCommandHandler>();
32+
services.AddScoped<IRequestHandler<RemoveIdentityResourceCommand, bool>, IdentityResourceCommandHandler>();
33+
services.AddScoped<IRequestHandler<UpdateIdentityResourceCommand, bool>, IdentityResourceCommandHandler>();
34+
35+
services.AddScoped<IRequestHandler<RegisterApiResourceCommand, bool>, ApiResourceCommandHandler>();
36+
37+
/*
38+
* Client commands
39+
*/
40+
services.AddScoped<IRequestHandler<RemoveClientCommand, bool>, ClientCommandHandler>();
41+
services.AddScoped<IRequestHandler<UpdateClientCommand, bool>, ClientCommandHandler>();
42+
services.AddScoped<IRequestHandler<RemoveClientSecretCommand, bool>, ClientCommandHandler>();
43+
services.AddScoped<IRequestHandler<SaveClientSecretCommand, bool>, ClientCommandHandler>();
44+
services.AddScoped<IRequestHandler<RemovePropertyCommand, bool>, ClientCommandHandler>();
45+
services.AddScoped<IRequestHandler<SaveClientPropertyCommand, bool>, ClientCommandHandler>();
46+
services.AddScoped<IRequestHandler<RemoveClientClaimCommand, bool>, ClientCommandHandler>();
47+
services.AddScoped<IRequestHandler<SaveClientClaimCommand, bool>, ClientCommandHandler>();
48+
services.AddScoped<IRequestHandler<SaveClientCommand, bool>, ClientCommandHandler>();
49+
services.AddScoped<IRequestHandler<CopyClientCommand, bool>, ClientCommandHandler>();
50+
}
51+
}
52+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Jp.Domain.Core.Notifications;
2+
using MediatR;
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace Jp.Application.Configuration
6+
{
7+
internal class DomainEventsBootStrapper
8+
{
9+
public static void RegisterServices(IServiceCollection services)
10+
{
11+
services.AddScoped<INotificationHandler<DomainNotification>, DomainNotificationHandler>();
12+
}
13+
}
14+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Jp.Application.Bus;
2+
using Jp.Domain.Core.Bus;
3+
using Microsoft.Extensions.Configuration;
4+
using Microsoft.Extensions.DependencyInjection;
5+
6+
namespace Jp.Application.Configuration
7+
{
8+
public class NativeInjectorBootStrapper
9+
{
10+
public static void RegisterServices(IServiceCollection services)
11+
{
12+
13+
// Domain Bus (Mediator)
14+
services.AddScoped<IMediatorHandler, InMemoryBus>();
15+
16+
// Application
17+
ApplicationBootStrapper.RegisterServices(services);
18+
19+
// Domain - Events
20+
DomainEventsBootStrapper.RegisterServices(services);
21+
22+
// Domain - Commands
23+
DomainCommandsBootStrapper.RegisterServices(services);
24+
25+
// Infra - Data
26+
RepositoryBootStrapper.RegisterServices(services);
27+
}
28+
}
29+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Jp.Domain.Core.Events;
2+
using Jp.Domain.Interfaces;
3+
using Jp.Infra.Data.Context;
4+
using Jp.Infra.Data.EventSourcing;
5+
using Jp.Infra.Data.Repository;
6+
using Jp.Infra.Data.Repository.EventSourcing;
7+
using Jp.Infra.Data.UoW;
8+
using Microsoft.Extensions.DependencyInjection;
9+
10+
namespace Jp.Application.Configuration
11+
{
12+
internal class RepositoryBootStrapper
13+
{
14+
public static void RegisterServices(IServiceCollection services)
15+
{
16+
services.AddScoped<IPersistedGrantRepository, PersistedGrantRepository>();
17+
services.AddScoped<IApiResourceRepository, ApiResourceRepository>();
18+
services.AddScoped<IApiScopeRepository, ApiScopeRepository>();
19+
20+
services.AddScoped<IIdentityResourceRepository, IdentityResourceRepository>();
21+
services.AddScoped<IClientRepository, ClientRepository>();
22+
services.AddScoped<IClientSecretRepository, ClientSecretRepository>();
23+
services.AddScoped<IApiSecretRepository, ApiSecretRepository>();
24+
25+
services.AddScoped<IClientClaimRepository, ClientClaimRepository>();
26+
services.AddScoped<IClientPropertyRepository, ClientPropertyRepository>();
27+
services.AddScoped<IUnitOfWork, UnitOfWork>();
28+
services.AddScoped<JpContext>();
29+
30+
// Infra - Data EventSourcing
31+
services.AddScoped<IEventStoreRepository, EventStoreRepository>();
32+
services.AddScoped<IEventStore, SqlEventStore>();
33+
services.AddScoped<EventStoreContext>();
34+
}
35+
}
36+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Jp.Domain.Core.Events;
2+
3+
namespace Jp.Application.EventSourcedNormalizers
4+
{
5+
public class EventHistoryData
6+
{
7+
public EventHistoryData(string action, string id, EventDetails details, string when, string who, string category, string ip)
8+
{
9+
Action = action;
10+
Id = id;
11+
When = when;
12+
Who = who;
13+
Category = category;
14+
Ip = ip;
15+
Details = details?.Metadata;
16+
}
17+
18+
public string Category { get; }
19+
public string Ip { get; }
20+
public string Action { get; }
21+
public string Id { get; }
22+
public string When { get; }
23+
public string Who { get; }
24+
public string Details { get; }
25+
}
26+
}

src/Backend/Jp.Application/Jp.Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<ProjectReference Include="..\Jp.Domain\Jp.Domain.csproj" />
14+
<ProjectReference Include="..\Jp.Infra.Data\Jp.Infra.Data.csproj" />
1515
</ItemGroup>
1616

1717
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Threading.Tasks;
2+
3+
namespace Jp.Domain.Core.Events
4+
{
5+
public interface IEventStore
6+
{
7+
Task Save<T>(T theEvent) where T : Event;
8+
}
9+
}

src/Backend/Jp.Domain/Commands/Clients/SaveClientCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public SaveClientCommand(string clientId, string name, string clientUri, string
2323
Description = description,
2424
};
2525

26-
if (postLogoutUri.IsMissing())
26+
if (postLogoutUri.IsPresent())
2727
Client.PostLogoutRedirectUris = new List<string>() { postLogoutUri };
2828
ClientType = clientType;
2929
}

0 commit comments

Comments
 (0)