Files
mixtape/zero.Demo/Program.cs
T

73 lines
2.1 KiB
C#
Raw Normal View History

2021-12-10 23:11:26 +01:00
using zero;
using zero.Api;
using zero.Applications;
2021-12-15 15:34:05 +01:00
using zero.Architecture;
2021-12-10 23:11:26 +01:00
using zero.Backoffice;
using zero.Backoffice.DevServer;
2021-12-29 01:25:35 +01:00
using zero.Commerce;
2021-12-22 00:14:48 +01:00
using zero.Configuration;
2021-12-10 23:11:26 +01:00
using zero.Demo;
using zero.Localization;
2021-12-10 23:11:26 +01:00
using zero.Routing;
2021-12-11 17:34:42 +01:00
using zero.Spaces;
using zero.Stores;
2021-12-10 23:11:26 +01:00
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddTransient<IApplicationResolverHandler, DevApplicationResolverHandler>();
2021-12-12 15:41:51 +01:00
builder.Services
2021-12-29 01:25:35 +01:00
.AddZero(builder.Configuration, cfg =>
{
cfg.Mvc.AddApplicationPart(typeof(CommercePlugin).Assembly);
})
2021-12-12 15:41:51 +01:00
.AddApi()
2021-12-29 01:25:35 +01:00
.AddBackoffice()
.AddCommerce();
2021-12-10 23:11:26 +01:00
builder.Services.Configure<ZeroDevOptions>(opts =>
{
opts.Enabled = false;
});
2021-12-11 17:34:42 +01:00
builder.Services.Configure<FlavorOptions>(opts =>
{
opts.AddSpaceList<TeamMember>("team", "Team", "Members of our team", "fth-users", "spaces.team");
2021-12-23 09:07:34 +01:00
opts.AddIntegration<FathomAnalyticsIntegration>("analytics.fathom", "Fathom Analytics", "Connect your website to Fathom and track page views", tags: new() { "analytics" }, imagePath: "/assets/fathom.png");
opts.AddIntegration<GoogleAnalyticsIntegration>("analytics.google", "Google Analytics", "Connect your website to google analytics", tags: new() { "analytics" }, imagePath: "/assets/googleanalytics.png");
2021-12-15 21:22:00 +01:00
opts.Configure<Country>(x => x.CanUseWithoutFlavors = false);
opts.Add<Country, EuropeanCountry>("eu_country", "EU country", "A country within the European Union", "fth-globe");
opts.Add<Country, AmericanCountry>("usa_country", "USA", "A country in the United States", "fth-flag");
2021-12-23 09:07:34 +01:00
2021-12-11 17:34:42 +01:00
});
2021-12-15 15:34:05 +01:00
builder.Services.Configure<BlueprintOptions>(opts =>
{
opts.Add<Country>();
2021-12-20 16:13:09 +01:00
opts.Add<Language>();
2021-12-21 14:41:50 +01:00
opts.Add<Translation>();
2021-12-15 15:34:05 +01:00
});
2021-12-10 23:11:26 +01:00
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseZero().WithEndpoints(x =>
{
2021-12-12 15:41:51 +01:00
//x.MapControllerRoute("default", "api/{controller}/{action=Index}/{id?}");
2021-12-13 12:21:15 +01:00
x.MapControllers();
2021-12-10 23:11:26 +01:00
x.MapRazorPages();
2021-12-13 13:40:04 +01:00
x.MapZeroApi();
x.MapZeroBackoffice();
2021-12-10 23:11:26 +01:00
x.MapZeroRoutes();
});
2021-12-12 15:41:51 +01:00
//app.UseZeroBackoffice();
2021-12-22 16:36:18 +01:00
app.Run();