-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConfigure.AppHost.cs
More file actions
109 lines (95 loc) · 3.44 KB
/
Configure.AppHost.cs
File metadata and controls
109 lines (95 loc) · 3.44 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Funq;
using ServiceStack;
using ServiceStack.Admin;
using ServiceStack.Configuration;
using ServiceStack.Desktop;
using ServiceStack.Script;
using ServiceStack.Text;
using ServiceStack.Validation;
using Studio.ServiceInterface;
[assembly: HostingStartup(typeof(Studio.AppHost))]
namespace Studio;
public class ExportTypes : IReturn<ExportTypes>
{
public AuditBase AuditBase { get; set; }
public EmptyResponse EmptyResponse { get; set; }
public IdResponse IdResponse { get; set; }
public StringResponse StringResponse { get; set; }
public StringsResponse StringsResponse { get; set; }
}
public class ExportTypesService : IService
{
public object Any(ExportTypes request) => request;
}
public class AppHost : AppHostBase, IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services => {
// Configure ASP.NET Core IOC Dependencies
})
.Configure(app => {
// Configure ASP.NET Core App
if (!HasInit)
app.UseServiceStack(new AppHost());
})
.ConfigureAppHost(afterPluginsLoaded: appHost => {
appHost.Plugins.Add(new HotReloadFeature {
VirtualFiles = appHost.VirtualFiles, //Monitor all folders for changes including /src & /wwwroot
});
});
public AppHost() : base("ServiceStack Studio", typeof(StudioServices).Assembly) {}
public override void Configure(Container container)
{
Env.StrictMode = true;
SetConfig(new HostConfig
{
DebugMode = AppSettings.Get("debug", HostingEnvironment.IsDevelopment()),
UseSecureCookies = true,
AddRedirectParamsToQueryString = true,
});
if (Config.DebugMode)
{
//generate types
RegisterService<GetCrudEventsService>("/crudevents/{Model}");
RegisterService<GetValidationRulesService>("/validation/rules/{Type}");
RegisterService<ModifyValidationRulesService>("/validation/rules");
RegisterService<AdminUsersService>("/ss_admin/users");
}
Plugins.Add(new SessionFeature()); // store client auth in session
// DartGenerator.ArrayTypes;
Plugins.Add(new SharpPagesFeature {
EnableSpaFallback = true,
ScriptMethods = { new AppScripts() }
// Args = { ["connect"] = "https://localhost:5001" } //test ?connect={url} import scheme
});
var sites = StudioServices.LoadAppSettings();
Plugins.Add(new DesktopFeature {
AccessRole = Config.DebugMode
? RoleNames.AllowAnon
: RoleNames.Admin,
ImportParams = {
"debug",
"connect",
},
ProxyConfigs = sites.Keys.Map(baseUrl => new Uri(baseUrl))
.Map(uri => new ProxyConfig {
Scheme = uri.Scheme,
TargetScheme = uri.Scheme,
Domain = uri.Host,
AllowCors = true,
IgnoreHeaders = { "X-Frame-Options", "Content-Security-Policy" },
})
});
}
public override void OnStartupException(Exception ex)
{
Console.WriteLine(ex);
base.OnStartupException(ex);
}
}
public class AppScripts : ScriptMethods
{
}