using Elsa.EntityFrameworkCore.Extensions; using Elsa.EntityFrameworkCore.Modules.Management; using Elsa.EntityFrameworkCore.Modules.Runtime; using Elsa.Extensions; using Elsa.Samples.WorkflowServer.Activities; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddElsa(elsa => { // Configure management feature to use EF Core. elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlite())); elsa.UseWorkflowRuntime(runtime => { runtime.UseDefaultRuntime(dr => dr.UseEntityFrameworkCore(ef => ef.UseSqlite())); runtime.UseExecutionLogRecords(e => e.UseEntityFrameworkCore(ef => ef.UseSqlite())); runtime.UseAsyncWorkflowStateExporter(); }); // Expose API endpoints. elsa.UseWorkflowsApi(); // Add services for HTTP activities and workflow middleware. elsa.UseHttp(); // Use timers. elsa.UseScheduling(); // Configure identity so that we can create a default admin user. elsa.UseIdentity(identity => { identity.IdentityOptions.CreateDefaultAdmin = builder.Environment.IsDevelopment(); identity.TokenOptions.SigningKey = "secret-token-signing-key"; }); // Use default authentication (JWT). elsa.UseDefaultAuthentication(); // Register custom activities. elsa.AddActivity(); }); // Configure CORS to allow designer app hosted on a different origin to invoke the APIs. builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod())); var app = builder.Build(); // Configure the HTTP request pipeline. app.UseHttpsRedirection(); app.UseCors(); app.UseAuthentication(); app.UseAuthorization(); app.UseWorkflowsApi(); app.UseWorkflows(); app.Run();