-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathStartup.cs
92 lines (78 loc) · 3.05 KB
/
Startup.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using EPiServer.Cms.Shell;
using EPiServer.Cms.UI.AspNetIdentity;
using EPiServer.ContentApi.Core.Configuration;
using EPiServer.ContentApi.Core.DependencyInjection;
namespace MusicFestival;
public class Startup
{
private readonly IWebHostEnvironment _webHostingEnvironment;
public Startup(IWebHostEnvironment webHostingEnvironment)
{
_webHostingEnvironment = webHostingEnvironment;
}
public void ConfigureServices(IServiceCollection services)
{
AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(_webHostingEnvironment.ContentRootPath, "App_Data"));
services
.AddCmsAspNetIdentity<ApplicationUser>()
.AddCms()
.AddAdminUserRegistration()
.AddEmbeddedLocalization<Program>()
.ConfigureForExternalTemplates()
.Configure<DisplayOptions>(options =>
{
options
.Add("full", "Full", "u-md-sizeFull", string.Empty, "epi-icon__layout--full")
.Add("wide", "Wide", "u-md-size2of3", string.Empty, "epi -icon__layout--two-thirds")
.Add("half", "Half", "u-md-size1of2", string.Empty, "epi-icon__layout--half")
.Add("narrow", "Narrow", "u-md-size1of3", string.Empty, "epi-icon__layout--one-third");
});
services.AddContentDeliveryApi();
services.ConfigureForContentDeliveryClient();
services.Configure<ContentApiOptions>(options =>
{
options.ForceAbsolute = false;
});
services.AddNodeJs(options =>
{
if (_webHostingEnvironment.IsDevelopment())
{
options.LaunchCommand = "npm run dev";
options.WorkingDirectory = "./ClientApp/";
options.RedirectOutput = false;
}
else
{
var port = 4000;
options.DestinationPort = port;
options.LaunchCommand = "node ./server/index.mjs";
// If server contains secrets, these files needs to be served from elsewhere.
// We can leverage the static file middleware by serving them from here.
options.WorkingDirectory = "./wwwroot/";
options.EnvironmentVariables = new Dictionary<string, string>
{
{ "PORT", port.ToString() },
{ "NUXT_PUBLIC_API_URL", "http://localhost:80/api/episerver/v3.0/" },
{ "NUXT_PUBLIC_WEBSITE_URL", "http://www.example.com/" }
};
}
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapContent();
endpoints.MapNodeJs();
});
}
}