Skip to content

Commit a761f09

Browse files
committed
#28 work on separate miniservice into standard, efcore, and mongodb templates
1 parent 08fb937 commit a761f09

26 files changed

+1329
-26
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ If you liked the project or if `netcorekit` helped you, please give a star so th
1616

1717
- [x] Simple libraries. No frameworks. Little abstraction.
1818
- [x] Opt-in and out of the box [features](https://github.com/cloudnative-netcore/netcorekit/wiki/Miniservice-template-guidance) with [Feature Toggles](https://martinfowler.com/articles/feature-toggles.html) technique.
19-
- [x] Generic repository for data persistence.
2019
- [x] Adhere to [twelve-factor app paradigm](https://12factor.net) and more.
21-
- [x] Resilience and health check out of the box.
22-
- [x] Easy for configuration management.
20+
- [x] Authentication/Authorization with OAuth 2.0 and OpenID Connect.
2321
- [x] [Domain-driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) in mind.
2422
- [x] Simply [Clean Architecture](http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) supports.
25-
- [x] Authentication/Authorization with OAuth 2.0 and OpenID Connect.
23+
- [x] Generic repository for data persistence.
24+
- [x] Mapping between domain entity to DTO and vice versa.
2625
- [x] Clean and demystify error, debug logs.
26+
- [x] Resilience and health check out of the box.
27+
- [x] Easy for configuration management.
2728
- [x] API versioning from Docker container to WebAPI.
2829
- [x] Documentation template with OpenAPI documentation.
2930
- [x] Work natively with Kubernetes or even with Service Mesh(Istio).
@@ -34,53 +35,53 @@ Small, lightweight, cloud-native out of the box, and much more simple to get sta
3435

3536
### Look how simple we can start as below:
3637

37-
- Without storage, merely calculation and job tasks:
38+
- Standard template - NetCoreKit.Template.Standard: without storage, merely calculation and job tasks:
3839

3940
```csharp
4041
public class Startup
4142
{
4243
public void ConfigureServices(IServiceCollection services)
4344
{
44-
services.AddMiniService();
45+
services.AddStandardTemplate();
4546
}
4647

4748
public void Configure(IApplicationBuilder app)
4849
{
49-
app.UseMiniService();
50+
app.UseStandardTemplate();
5051
}
5152
}
5253
```
5354

54-
- With Entity Framework Core (SQL Server, MySQL, and SQLite providers) comes along with the generic repository in place:
55+
- EfCore template - NetCoreKit.Template.EfCore: with Entity Framework Core (SQL Server, MySQL, and SQLite providers) comes along with the generic repository in place:
5556

5657
```csharp
5758
public class Startup
5859
{
5960
public void ConfigureServices(IServiceCollection services)
6061
{
61-
services.AddEfCoreMiniService<TodoListDbContext>(svc => svc.AddEfCoreMySqlDb());
62+
services.AddEfCoreTemplate<TodoListDbContext>(svc => svc.AddEfCoreMySqlDb());
6263
}
6364

6465
public void Configure(IApplicationBuilder app)
6566
{
66-
app.UseMiniService();
67+
app.UseEfCoreTemplate();
6768
}
6869
}
6970
```
7071

71-
- With NoSQL (MongoDb provider) comes along with the generic repository in place:
72+
- MongoDb template - NetCoreKit.Template.MongoDb: with NoSQL (MongoDb provider) comes along with the generic repository in place:
7273

7374
```csharp
7475
public class Startup
7576
{
7677
public void ConfigureServices(IServiceCollection services)
7778
{
78-
services.AddMongoMiniService();
79+
services.AddMongoTemplate();
7980
}
8081

8182
public void Configure(IApplicationBuilder app)
8283
{
83-
app.UseMiniService();
84+
app.UseMongoTemplate();
8485
}
8586
}
8687
```

build.cake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var libs = new List<string>{
2121
"./src/NetCoreKit.Infrastructure.Mongo/NetCoreKit.Infrastructure.Mongo.csproj",
2222
"./src/NetCoreKit.Infrastructure.Bus/NetCoreKit.Infrastructure.Bus.csproj",
2323
"./src/NetCoreKit.Infrastructure.Bus.Kafka/NetCoreKit.Infrastructure.Bus.Kafka.csproj",
24-
"./src/NetCoreKit.Infrastructure.Bus.Redis/NetCoreKit.Infrastructure.Bus.Redis.csproj"
24+
"./src/NetCoreKit.Infrastructure.Bus.Redis/NetCoreKit.Infrastructure.Bus.Redis.csproj",
25+
"./templates/NetCoreKit.Template.Standard/NetCoreKit.Template.Standard.csproj",
26+
"./templates/NetCoreKit.Template.EfCore/NetCoreKit.Template.EfCore.csproj",
27+
"./templates/NetCoreKit.Template.MongoDb/NetCoreKit.Template.MongoDb.csproj"
2528
};
2629

2730
Task("Clean")

netcorekit.sln

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Samples.BiMoneta
7272
EndProject
7373
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreKit.Samples.TodoApi", "samples\TodoApi\NetCoreKit.Samples.TodoApi.csproj", "{BF6A7924-82C2-4471-AB03-99DD1259D454}"
7474
EndProject
75+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{4A2D1031-E1FD-43BB-B8D3-F570F4020A29}"
76+
EndProject
77+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCoreKit.Template.Standard", "templates\NetCoreKit.Template.Standard\NetCoreKit.Template.Standard.csproj", "{78525DA7-EC37-4364-875F-0DFAE951A066}"
78+
EndProject
79+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCoreKit.Template.EfCore", "templates\NetCoreKit.Template.EfCore\NetCoreKit.Template.EfCore.csproj", "{EAEEE731-2708-47AB-A26C-CC64CFB842EA}"
80+
EndProject
81+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCoreKit.Template.MongoDb", "templates\NetCoreKit.Template.MongoDb\NetCoreKit.Template.MongoDb.csproj", "{1C91E302-7210-4970-8915-0A2247C5E894}"
82+
EndProject
83+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetCoreKit.Infrastructure.AspNetCore.All", "src\NetCoreKit.Infrastructure.AspNetCore.All\NetCoreKit.Infrastructure.AspNetCore.All.csproj", "{B19A199A-B86D-46D7-9020-0846C3BD7733}"
84+
EndProject
7585
Global
7686
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7787
Debug|Any CPU = Debug|Any CPU
@@ -240,6 +250,38 @@ Global
240250
{BF6A7924-82C2-4471-AB03-99DD1259D454}.Release|Any CPU.Build.0 = Release|Any CPU
241251
{BF6A7924-82C2-4471-AB03-99DD1259D454}.Release|x86.ActiveCfg = Release|Any CPU
242252
{BF6A7924-82C2-4471-AB03-99DD1259D454}.Release|x86.Build.0 = Release|Any CPU
253+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
254+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Debug|Any CPU.Build.0 = Debug|Any CPU
255+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Debug|x86.ActiveCfg = Debug|Any CPU
256+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Debug|x86.Build.0 = Debug|Any CPU
257+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Release|Any CPU.ActiveCfg = Release|Any CPU
258+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Release|Any CPU.Build.0 = Release|Any CPU
259+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Release|x86.ActiveCfg = Release|Any CPU
260+
{78525DA7-EC37-4364-875F-0DFAE951A066}.Release|x86.Build.0 = Release|Any CPU
261+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
262+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
263+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Debug|x86.ActiveCfg = Debug|Any CPU
264+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Debug|x86.Build.0 = Debug|Any CPU
265+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
266+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Release|Any CPU.Build.0 = Release|Any CPU
267+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Release|x86.ActiveCfg = Release|Any CPU
268+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA}.Release|x86.Build.0 = Release|Any CPU
269+
{1C91E302-7210-4970-8915-0A2247C5E894}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
270+
{1C91E302-7210-4970-8915-0A2247C5E894}.Debug|Any CPU.Build.0 = Debug|Any CPU
271+
{1C91E302-7210-4970-8915-0A2247C5E894}.Debug|x86.ActiveCfg = Debug|Any CPU
272+
{1C91E302-7210-4970-8915-0A2247C5E894}.Debug|x86.Build.0 = Debug|Any CPU
273+
{1C91E302-7210-4970-8915-0A2247C5E894}.Release|Any CPU.ActiveCfg = Release|Any CPU
274+
{1C91E302-7210-4970-8915-0A2247C5E894}.Release|Any CPU.Build.0 = Release|Any CPU
275+
{1C91E302-7210-4970-8915-0A2247C5E894}.Release|x86.ActiveCfg = Release|Any CPU
276+
{1C91E302-7210-4970-8915-0A2247C5E894}.Release|x86.Build.0 = Release|Any CPU
277+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
278+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Debug|Any CPU.Build.0 = Debug|Any CPU
279+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Debug|x86.ActiveCfg = Debug|Any CPU
280+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Debug|x86.Build.0 = Debug|Any CPU
281+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Release|Any CPU.ActiveCfg = Release|Any CPU
282+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Release|Any CPU.Build.0 = Release|Any CPU
283+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Release|x86.ActiveCfg = Release|Any CPU
284+
{B19A199A-B86D-46D7-9020-0846C3BD7733}.Release|x86.Build.0 = Release|Any CPU
243285
EndGlobalSection
244286
GlobalSection(SolutionProperties) = preSolution
245287
HideSolutionNode = FALSE
@@ -267,6 +309,10 @@ Global
267309
{BAAB999F-EF03-4575-8FD4-9989A544319E} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
268310
{1BE9EF11-ED30-4DC7-A12E-2D915E8DA85E} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
269311
{BF6A7924-82C2-4471-AB03-99DD1259D454} = {92D6FD73-B95C-4CBB-A48E-047672EB4E77}
312+
{78525DA7-EC37-4364-875F-0DFAE951A066} = {4A2D1031-E1FD-43BB-B8D3-F570F4020A29}
313+
{EAEEE731-2708-47AB-A26C-CC64CFB842EA} = {4A2D1031-E1FD-43BB-B8D3-F570F4020A29}
314+
{1C91E302-7210-4970-8915-0A2247C5E894} = {4A2D1031-E1FD-43BB-B8D3-F570F4020A29}
315+
{B19A199A-B86D-46D7-9020-0846C3BD7733} = {6CF50533-EBD6-47B1-9AD9-9EBBFF3AC887}
270316
EndGlobalSection
271317
GlobalSection(ExtensibilityGlobals) = postSolution
272318
SolutionGuid = {B9325AE8-21A8-4D46-9B04-38BD2BC35C0F}

samples/BiMonetaryApi/NetCoreKit.Samples.BiMonetaryApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
<ItemGroup>
1313
<ProjectReference Include="..\..\src\NetCoreKit.Domain\NetCoreKit.Domain.csproj" />
1414
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.CleanArch\NetCoreKit.Infrastructure.AspNetCore.CleanArch.csproj" />
15-
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.Miniservice\NetCoreKit.Infrastructure.AspNetCore.Miniservice.csproj" />
1615
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.OpenApi\NetCoreKit.Infrastructure.AspNetCore.OpenApi.csproj" />
1716
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore\NetCoreKit.Infrastructure.AspNetCore.csproj" />
1817
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.Mongo\NetCoreKit.Infrastructure.Mongo.csproj" />
1918
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure\NetCoreKit.Infrastructure.csproj" />
2019
<ProjectReference Include="..\..\src\NetCoreKit.Utils\NetCoreKit.Utils.csproj" />
20+
<ProjectReference Include="..\..\templates\NetCoreKit.Template.MongoDb\NetCoreKit.Template.MongoDb.csproj" />
2121
</ItemGroup>
2222

2323
</Project>

samples/BiMonetaryApi/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
using Microsoft.AspNetCore.Builder;
22
using Microsoft.Extensions.DependencyInjection;
3-
using NetCoreKit.Infrastructure.AspNetCore.Miniservice;
3+
using NetCoreKit.Template.MongoDb;
44

55
namespace NetCoreKit.Samples.BiMonetaryApi
66
{
77
public class Startup
88
{
99
public void ConfigureServices(IServiceCollection services)
1010
{
11-
services.AddMongoMiniService();
11+
services.AddMongoDbTemplate();
1212
}
1313

1414
public void Configure(IApplicationBuilder app)
1515
{
16-
app.UseMiniService();
16+
app.UseMongoDbTemplate();
1717
}
1818
}
1919
}

samples/TodoApi/NetCoreKit.Samples.TodoApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<ItemGroup>
1818
<ProjectReference Include="..\..\src\NetCoreKit.Domain\NetCoreKit.Domain.csproj" />
1919
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.CleanArch\NetCoreKit.Infrastructure.AspNetCore.CleanArch.csproj" />
20-
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.Miniservice\NetCoreKit.Infrastructure.AspNetCore.Miniservice.csproj" />
2120
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore.OpenApi\NetCoreKit.Infrastructure.AspNetCore.OpenApi.csproj" />
2221
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore\NetCoreKit.Infrastructure.AspNetCore.csproj" />
2322
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.Bus.Kafka\NetCoreKit.Infrastructure.Bus.Kafka.csproj" />
@@ -28,6 +27,7 @@
2827
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.EfCore\NetCoreKit.Infrastructure.EfCore.csproj" />
2928
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure\NetCoreKit.Infrastructure.csproj" />
3029
<ProjectReference Include="..\..\src\NetCoreKit.Utils\NetCoreKit.Utils.csproj" />
30+
<ProjectReference Include="..\..\templates\NetCoreKit.Template.EfCore\NetCoreKit.Template.EfCore.csproj" />
3131
<ProjectReference Include="..\Contracts\NetCoreKit.Samples.Contracts.csproj" />
3232
</ItemGroup>
3333

samples/TodoApi/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
using Microsoft.AspNetCore.Builder;
22
using Microsoft.Extensions.DependencyInjection;
3-
using NetCoreKit.Infrastructure.AspNetCore.Miniservice;
43
using NetCoreKit.Infrastructure.Bus;
54
using NetCoreKit.Infrastructure.Bus.Redis;
65
using NetCoreKit.Infrastructure.EfCore.MySql;
76
using NetCoreKit.Samples.TodoAPI.Domain;
87
using NetCoreKit.Samples.TodoAPI.Infrastructure.Db;
98
using NetCoreKit.Samples.TodoAPI.Infrastructure.Gateways;
9+
using NetCoreKit.Template.EfCore;
1010

1111
namespace NetCoreKit.Samples.TodoAPI
1212
{
1313
public class Startup
1414
{
1515
public void ConfigureServices(IServiceCollection services)
1616
{
17-
services.AddEfCoreMiniService<TodoListDbContext>(
17+
services.AddEfCoreTemplate<TodoListDbContext>(
1818
svc =>
1919
{
2020
//svc.AddEfSqlLiteDb();
@@ -30,7 +30,7 @@ public void ConfigureServices(IServiceCollection services)
3030

3131
public void Configure(IApplicationBuilder app)
3232
{
33-
app.UseMiniService();
33+
app.UseEfCoreTemplate();
3434
}
3535
}
3636
}

src/NetCoreKit.Domain/EntityBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
namespace NetCoreKit.Domain
99
{
10+
/// <inheritdoc />
11+
/// <summary>
12+
/// Supertype for all Entity types
13+
/// </summary>
1014
public interface IEntity : IIdentity
1115
{ }
1216

@@ -75,6 +79,7 @@ public IAggregateRoot RemoveEvent(IEvent @event)
7579
}
7680
}
7781

82+
/// <inheritdoc />
7883
/// <summary>
7984
/// Source: https://github.com/VaughnVernon/IDDD_Samples_NET
8085
/// </summary>

src/NetCoreKit.Domain/IDto.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace NetCoreKit.Domain
2+
{
3+
/// <summary>
4+
/// Supertype for all Dto types
5+
/// </summary>
6+
public interface IDto
7+
{
8+
}
9+
}

src/NetCoreKit.Domain/IEvent.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace NetCoreKit.Domain
55
{
6+
/// <summary>
7+
/// Supertype for all Event types
8+
/// </summary>
69
public interface IEvent
710
{
811
int EventVersion { get; }

0 commit comments

Comments
 (0)