Skip to content

Commit ff4342a

Browse files
committed
Introduce Elsa.ModularServer.Web with a minimal API, restructure shell feature configuration, and remove obsolete CShells dependency
1 parent 096202d commit ff4342a

10 files changed

Lines changed: 139 additions & 125 deletions

File tree

Elsa.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "issue_templates", "issue_te
337337
EndProject
338338
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dsl", "dsl", "{477C2416-312D-46AE-BCD6-8FA1FAB43624}"
339339
EndProject
340+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ModularServer.Web", "src\apps\Elsa.ModularServer.Web\Elsa.ModularServer.Web.csproj", "{E9CA9A0B-6180-4CA7-814C-FA60D1F1B6EC}"
341+
EndProject
340342
Global
341343
GlobalSection(SolutionConfigurationPlatforms) = preSolution
342344
Debug|Any CPU = Debug|Any CPU
@@ -593,6 +595,10 @@ Global
593595
{2B7FB49D-E4B6-4AD5-981B-3D85B94F6F48}.Debug|Any CPU.Build.0 = Debug|Any CPU
594596
{2B7FB49D-E4B6-4AD5-981B-3D85B94F6F48}.Release|Any CPU.ActiveCfg = Release|Any CPU
595597
{2B7FB49D-E4B6-4AD5-981B-3D85B94F6F48}.Release|Any CPU.Build.0 = Release|Any CPU
598+
{E9CA9A0B-6180-4CA7-814C-FA60D1F1B6EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
599+
{E9CA9A0B-6180-4CA7-814C-FA60D1F1B6EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
600+
{E9CA9A0B-6180-4CA7-814C-FA60D1F1B6EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
601+
{E9CA9A0B-6180-4CA7-814C-FA60D1F1B6EC}.Release|Any CPU.Build.0 = Release|Any CPU
596602
EndGlobalSection
597603
GlobalSection(SolutionProperties) = preSolution
598604
HideSolutionNode = FALSE
@@ -695,6 +701,7 @@ Global
695701
{2B7FB49D-E4B6-4AD5-981B-3D85B94F6F48} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
696702
{477C2416-312D-46AE-BCD6-8FA1FAB43624} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
697703
{874F5A44-DB06-47AB-A18C-2D13942E0147} = {477C2416-312D-46AE-BCD6-8FA1FAB43624}
704+
{E9CA9A0B-6180-4CA7-814C-FA60D1F1B6EC} = {D92BEAB2-60D6-4BB4-885A-6BA681C6CCF1}
698705
EndGlobalSection
699706
GlobalSection(ExtensibilityGlobals) = postSolution
700707
SolutionGuid = {D4B5CEAA-7D70-4FCB-A68E-B03FBE5E0E5E}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
var app = builder.Build();
3+
4+
app.MapGet("/", () => "Hello World!");
5+
6+
app.Run();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:5002",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": true,
17+
"applicationUrl": "https://localhost:7293;http://localhost:5002",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
<ProjectReference Include="..\..\modules\Elsa.Tenants.AspNetCore\Elsa.Tenants.AspNetCore.csproj" />
2323
<ProjectReference Include="..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
2424
</ItemGroup>
25-
26-
<ItemGroup>
27-
<PackageReference Include="CShells.AspNetCore" />
28-
</ItemGroup>
2925

3026
<ItemGroup>
3127
<Folder Include="App_Data\" />

src/apps/Elsa.Server.Web/Features/ActivitiesAndWorkflowsFeature.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/apps/Elsa.Server.Web/Features/TempElsaFeature.cs

Lines changed: 0 additions & 103 deletions
This file was deleted.

src/apps/Elsa.Server.Web/Program.cs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,83 @@
3939
var identitySection = configuration.GetSection("Identity");
4040
var identityTokenSection = identitySection.GetSection("Tokens");
4141

42-
builder.AddShells();
43-
42+
services
43+
.AddElsa(elsa =>
44+
{
45+
elsa
46+
.AddActivitiesFrom<Program>()
47+
.AddWorkflowsFrom<Program>()
48+
.UseIdentity(identity =>
49+
{
50+
identity.TokenOptions += options => identityTokenSection.Bind(options);
51+
identity.UseConfigurationBasedUserProvider(options => identitySection.Bind(options));
52+
identity.UseConfigurationBasedApplicationProvider(options => identitySection.Bind(options));
53+
identity.UseConfigurationBasedRoleProvider(options => identitySection.Bind(options));
54+
})
55+
.UseDefaultAuthentication()
56+
.UseWorkflows(workflows =>
57+
{
58+
workflows.UseCommitStrategies(strategies =>
59+
{
60+
strategies.AddStandardStrategies();
61+
strategies.Add("Every 10 seconds", new PeriodicWorkflowStrategy(TimeSpan.FromSeconds(10)));
62+
});
63+
})
64+
.UseWorkflowManagement(management =>
65+
{
66+
management.UseEntityFrameworkCore(ef => ef.UseSqlite());
67+
management.SetDefaultLogPersistenceMode(LogPersistenceMode.Inherit);
68+
management.UseCache();
69+
management.UseReadOnlyMode(useReadOnlyMode);
70+
})
71+
.UseWorkflowRuntime(runtime =>
72+
{
73+
runtime.UseEntityFrameworkCore(ef => ef.UseSqlite());
74+
runtime.UseCache();
75+
runtime.UseDistributedRuntime();
76+
})
77+
.UseWorkflowsApi()
78+
.UseFluentStorageProvider()
79+
.UseElsaScriptBlobStorage()
80+
.UseScheduling()
81+
.UseCSharp(options =>
82+
{
83+
options.DisableWrappers = disableVariableWrappers;
84+
options.AppendScript("string Greet(string name) => $\"Hello {name}!\";");
85+
options.AppendScript("string SayHelloWorld() => Greet(\"World\");");
86+
})
87+
.UseJavaScript(options =>
88+
{
89+
options.AllowClrAccess = true;
90+
options.ConfigureEngine(engine =>
91+
{
92+
engine.Execute("function greet(name) { return `Hello ${name}!`; }");
93+
engine.Execute("function sayHelloWorld() { return greet('World'); }");
94+
});
95+
})
96+
.UsePython(python =>
97+
{
98+
python.PythonOptions += options =>
99+
{
100+
// Make sure to configure the path to the python DLL. E.g. /opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/bin/python3.11
101+
// alternatively, you can set the PYTHONNET_PYDLL environment variable.
102+
configuration.GetSection("Scripting:Python").Bind(options);
103+
104+
options.AddScript(sb =>
105+
{
106+
sb.AppendLine("def greet():");
107+
sb.AppendLine(" return \"Hello, welcome to Python!\"");
108+
});
109+
};
110+
})
111+
.UseLiquid(liquid => liquid.FluidOptions = options => options.Encoder = HtmlEncoder.Default)
112+
.UseHttp(http =>
113+
{
114+
http.ConfigureHttpOptions = options => configuration.GetSection("Http").Bind(options);
115+
http.UseCache();
116+
});
117+
ConfigureForTest?.Invoke(elsa);
118+
});
44119

45120
// Obfuscate HTTP request headers.
46121
services.AddActivityStateFilter<HttpRequestAuthenticationHeaderFilter>();

0 commit comments

Comments
 (0)