forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
74 lines (61 loc) · 2.28 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Elsa.Elasticsearch.Extensions;
using Elsa.Elasticsearch.Modules.Management;
using Elsa.Elasticsearch.Modules.Runtime;
using Elsa.EntityFrameworkCore.Extensions;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
// Add services to the container.
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management =>
{
management.UseWorkflowDefinitions(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
management.UseWorkflowInstances(i => i.UseElasticsearch());
});
// Configure Elasticsearch.
elsa.UseElasticsearch(options => configuration.GetSection("Elasticsearch").Bind(options));
// Configure runtime feature to use EF Core.
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseDefaultRuntime(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
runtime.UseExecutionLogRecords(log => log.UseElasticsearch());
runtime.UseAsyncWorkflowStateExporter();
});
// Expose API endpoints.
elsa.UseWorkflowsApi(api => api.AddFastEndpointsAssembly<Program>());
// Add services for HTTP activities and workflow middleware.
elsa.UseHttp();
// Use JavaScript and Liquid.
elsa.UseJavaScript();
elsa.UseLiquid();
// Configure identity so that we can create a default admin user.
elsa.UseIdentity(identity =>
{
identity.UseAdminUserProvider();
identity.TokenOptions = options =>
{
options.SigningKey = "secret-token-signing-key";
options.AccessTokenLifetime = TimeSpan.FromDays(1);
};
});
// Use default authentication (JWT).
elsa.UseDefaultAuthentication();
});
builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
// Add Razor pages.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseCors();
app.UseStaticFiles();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseWorkflows();
app.MapRazorPages();
app.Run();