elsa-core/src/samples/aspnet/Elsa.Samples.WorkflowServerAndDesigner/Program.cs

53 lines
1.5 KiB
C#
Raw Normal View History

using Elsa.EntityFrameworkCore.Extensions;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
2023-01-12 18:26:30 +00:00
elsa.UseWorkflowManagement(management =>
{
management.UseEntityFrameworkCore(ef => ef.UseSqlite());
});
// Configure the default runtime feature to use EF Core.
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseDefaultRuntime(defaultRuntime => defaultRuntime.UseEntityFrameworkCore(ef => ef.UseSqlite()));
2023-01-12 18:26:30 +00:00
});
// Expose API endpoints.
elsa.UseWorkflowsApi();
// Add services for HTTP activities and workflow middleware.
elsa.UseHttp();
// Configure identity so that we can create a default admin user.
elsa.UseIdentity(identity =>
{
2023-01-01 21:54:07 +00:00
identity.IdentityOptions.CreateDefaultAdmin = builder.Environment.IsDevelopment();
identity.TokenOptions.SigningKey = "secret-token-signing-key";
});
// Use default authentication (JWT).
elsa.UseDefaultAuthentication();
});
// Add Razor pages.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseWorkflows();
app.MapRazorPages();
app.Run();