A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic ๐
MIT License
Bot releases are visible (Hide)
Published by pdevito3 almost 3 years ago
fixed an issue with the seeder for private entities
Published by pdevito3 almost 3 years ago
This is a prerelease that drives for more ddd based entities. entities now have private setters, factory methods, and updated tests and seeders.
Published by pdevito3 almost 3 years ago
Published by pdevito3 almost 3 years ago
Consumes
from Get listPublished by pdevito3 almost 3 years ago
Lots and lots of updates to this release with things I've been wanting to add and more lessons learned as I continue to dogfood things.
Some of the major items in here:
Startup
and Program
yet, but may in v0.13.new:example
command. I wanted to make it really easy to see examples for different types of scenarios, so I added a new command to easily get something together. Just runcraftsman new:example
and follow the prompts!BaseEntitiy
that has a standardized Id
Guid for your primary key and audit fields as well. These will be updated for you OOTB in db context now.There's so much more as well. I think the project scaffolding is really moving in a good direction and is getting closer to a more stable position. Lots to add still, but it's at least starting to feel more mature.
As always, check out the docs for updates.
Also, I started a discord channel if you want to come join us! Feel free to reach out if you have any questions or issues.
Added BaseEntity
that all entities will inherit from.
Guid
of Id
marked as the primary keyCreatedOn
, CreatedBy
, LastModifiedOn
, and LastModifiedBy
propertiesAdded a CurrentUserService
to add a user to the CreatedBy
and LastModifiedBy
properties if a user is found. Built into db context
Added built in features to the add:feature
command
New AddListByFk
option for the add:feature
command and Feature
property of an entity.
New craftsman example
or craftsman new:example
command to create an example project with a prompted workflow to select. Basic
, WithAuth
, AuthServer
, WithBus
Added .DS_Store
and .env
to gitignore
Added Consumer test
Added provider
to test fixture when adding a bus
Added a mock IPublishEndpoint
service to TestFixture
when using MassTransit
New policies added to swagger on add:entity
scaffolding
New add:authserver
command as well as an AuthServer
option when creating a domain
Added helper GetService
method to TestFixture
Added Creation and Update Validators back to scaffolding. Easy enough to delete if you aren't using them
Added a NamingConvention
property to the db template
Class
SnakeCase
LowerCase
CamelCase
UpperCase
Updated to .NET 6
Updated nuget packages
HttpStatusCode.XXX
)TestBase
update for postgresto include 1.Seconds()
await act.Should().ThrowAsync<
where appropriateMoved Policies to Feature
There is no more primary key property. A Guid with a name Id
will be inherited by all entities.
Docker utilities for integration test refactored to use Fluent Docker wherever possible for better readability. Some enhancements were made as well (e.g. better container/volume naming, proper volume mounting).
Removed ErrorHandlerMiddleware
and replaced it with ErrorHandlerFilterAttribute
Cleaned up test names
Modified CORS util to take in env
Added Secret
back to Environment options
Added local config utilities for testing environments
Remove UseInMemoryDb
app setting in favor of environment specific checks
Remove UseInMemoryBus
app setting in favor of environment specific checks
Using statement shortening for reset function in test fixture
Consolidated multiple environments startups to one startup file
Update logging registration in Program.cs
to no longer rely on appsettings
Updated FK support to better API
Moved env config from appsettings to environment variables
Production env no longer added by default
Features now include missing cancellation tokens as well as AsNoTracking
properties
Removed automatic fluent validation to allow more control in domain operations. For example:
var validator = new RecipeForCreationDtoValidator();
validator.ValidateAndThrow(recipeForCreationDto);
WebApiServiceExtension
by updating .AddFluentValidation(cfg => { cfg.AutomaticValidationEnabled = false; });
409
produced response annotation on POSTPublished by pdevito3 about 3 years ago
fix: removed extra )
from endpoint names
Published by pdevito3 about 3 years ago
This release has a lot of little cleanup items, as I've had the opportunity to dogfood this a bit and find a bunch of things that need fixing. I still plan on bringing in some of the big heavy hitting wins in v0.12.
Of note for this release was consolidating the 3 bounded context projects into one single project to promote simplicity and not prematurely optimizing. Additionally, there is a new add:feature
command to quickly scaffold new features. More on this coming in v0.12.
As always, check out the docs for updates.
add:feature
command (also works with new:feature
)Guid.NewGuid()
unless otherwise specifiedfeatures
option to entities to allow for granular feature control. The accepted values are AdHoc
, GetRecord
, GetList
, DeleteRecord
, UpdateRecord
, PatchRecord
, AddRecord
, and CreateRecord
(same as AddRecord
but available as an alias in case you can't remember!)webapi
suffix on the api projectContexts
dir changed to Databases
NoKeyGenerated
commands are no longer in dbcontextDummyData
directorySolutionName
to ProjectName
isRequired
propertyUpdate
command has proper casingRemoved the add:property
cli - command
Published by pdevito3 over 3 years ago
Huge release incoming! It includes a ton of stuff. Most notably:
add:bus
commandadd:consumer
and add:producer
commands for direct, topic, and fanout messagesadd:message
commandnew:domain
output to a single solution with directories for each bounded context for easier managementStartupDevelopment.cs
to commentsProgram.cs
add:entity
and add:prop
to now be called from the BC directoryProducesResponseType
in controllers to generic Response
type where applicableProgram.cs
to asyncnew:domain
command (#24)list
commandControllerBase
instead of Controller
. fixes (#26)Guid.NewGuid()
in their creation dtoadd:bc
commandPublished by pdevito3 over 3 years ago
Published by pdevito3 over 3 years ago
Published by pdevito3 over 3 years ago
Published by pdevito3 over 3 years ago
ordering
is ordering.webapi
new:domain
command to create a ddd based domain with various bounded contexts inside of it. this is recommended for long term maintainabilityadd:bc
command which will add a new bounded context to your ddd projectversion
or -v
command to get the craftsman versionadd:prop
aliasmicro
command to consolidate and reduce complexity. if you still want to build a microservice, you can build a domain and deploy each bounded context as a microservice
new:api
command to focus on the DDD driven styleClientSecret
to promote code+PKCE flowPublished by pdevito3 over 3 years ago
Published by pdevito3 over 3 years ago
Published by pdevito3 over 3 years ago
add:micro
command that scaffolds a new microservice template as well as an ocelot gatewayport
property on the new:api
template to let you customize and api or microservice port on localhosthttps
default on localUseHsts
for non dev environmentsUseHttpsRedirection
with notes on even more secure optionsAuthorizationSettings
object and authorization based properties on the environments for the new:api
and new:micro
commandsGetEntity
and DeleteEntity
integration tests with and without authCurrentStartIndex
calculation in the PagedList
class was broken and now has a new calculation.?.
) to certain tests before .Data
to make them fail more gracefully
WebApplicationFactory
to remove deprecated services.[Collection(""Sequential"")]
from repo testsPublished by pdevito3 almost 4 years ago
UseEnvironment
in WebAppFactory to use Development
Response
wrapperPublished by pdevito3 almost 4 years ago
WebApi.csproj
and the Swagger configPublished by pdevito3 almost 4 years ago
This release requires an update of your foundation template to v0.4.0 You can upgrade by running this command:
dotnet new Foundation.Api --update-apply
Development
. For non-Development environments, you'll need to add whatever logging you're interested in to their respective app-settings projects. There are just too many options to create a whole API on top of Serilog. for upgrade instructions see below.Program.cs
[FromBody]
markerBasePaginationParameters
will now have MaxPageSize
and DefaultPageSize
set as internal
properties so they don't show up in swagger. These can be overridden in the distinct entity classes like so: internal override int MaxPageSize { get; } = 30;
Add the below packages to your webapi project and remove the Nswag
package:
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
In Webapi ServiceExtensions
replace using NSwag
with using Microsoft.OpenApi.Models;
and update the swagger region to something like the below with the appropriate info for your project:
#region Swagger Region - Do Not Delete
public static void AddSwaggerExtension(this IServiceCollection services)
{
services.AddSwaggerGen(config =>
{
config.SwaggerDoc(
"v1",
new OpenApiInfo
{
Version = "v1",
Title = "",
Description = "",
Contact = new OpenApiContact
{
Name = "",
Email = "",
Url = new Uri(""),
},
});
});
}
#endregion
In Webapi AppExtensions
, update the swagger region to the below:
#region Swagger Region - Do Not Delete
public static void UseSwaggerExtension(this IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "");
});
}
#endregion
If you have an existing project and want to add this to your project, you'll need do this manually :
Add the following packages to webapi:
Update your Program
to the following:
namespace WebApi
{
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using System;
using System.IO;
using System.Reflection;
public class Program
{
public static void Main(string[] args)
{
var myEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var appSettings = myEnv == null ? $"appsettings.json" : $"appsettings.{myEnv}.json";
//Read Configuration from appSettings
var config = new ConfigurationBuilder()
.AddJsonFile(appSettings)
.Build();
//Initialize Logger
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(config)
.CreateLogger();
try
{
Log.Information("Starting application");
CreateHostBuilder(args)
.Build()
.Run();
}
catch (Exception e)
{
Log.Error(e, "The application failed to start correctly");
throw;
}
finally
{
Log.Information("Shutting down application");
Log.CloseAndFlush();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup(typeof(Startup).GetTypeInfo().Assembly.FullName)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel();
});
}
}
appsettings.Development
to:{
"AllowedHosts": "*",
"UseInMemoryDatabase": true,
"Serilog": {
"Using": [],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "Seq",
"Args": {
"serverUrl": "http://localhost:5341"
}
}
]
},
}
Published by pdevito3 almost 4 years ago
add:entities
alias for the add:entity
commandPublished by pdevito3 almost 4 years ago
StartupDevelopment
when using add:entity
command