-
-
Notifications
You must be signed in to change notification settings - Fork 749
Expand file tree
/
Copy pathStartup.cs
More file actions
97 lines (92 loc) · 3.97 KB
/
Startup.cs
File metadata and controls
97 lines (92 loc) · 3.97 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
using BlazorHero.CleanArchitecture.Application.Extensions;
using BlazorHero.CleanArchitecture.Infrastructure.Extensions;
using BlazorHero.CleanArchitecture.Server.Extensions;
using BlazorHero.CleanArchitecture.Server.Middlewares;
using Hangfire;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using System.IO;
using BlazorHero.CleanArchitecture.Server.Filters;
using BlazorHero.CleanArchitecture.Server.Managers.Preferences;
using Microsoft.Extensions.Localization;
namespace BlazorHero.CleanArchitecture.Server
{
public class Startup
{
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
private readonly IConfiguration _configuration;
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddForwarding(_configuration);
services.AddLocalization(options =>
{
options.ResourcesPath = "Resources";
});
services.AddCurrentUserService();
services.AddSerialization();
services.AddDatabase(_configuration);
services.AddServerStorage(); //TODO - should implement ServerStorageProvider to work correctly!
services.AddScoped<ServerPreferenceManager>();
services.AddServerLocalization();
services.AddIdentity();
services.AddJwtAuthentication(services.GetApplicationSettings(_configuration));
services.AddSignalR();
services.AddApplicationLayer();
services.AddApplicationServices();
services.AddRepositories();
services.AddExtendedAttributesUnitOfWork();
services.AddSharedInfrastructure(_configuration);
services.RegisterSwagger();
services.AddInfrastructureMappings();
services.AddHangfire(x => x.UseSqlServerStorage(_configuration.GetConnectionString("DefaultConnection")));
services.AddHangfireServer();
services.AddControllers().AddValidators();
services.AddExtendedAttributesValidators();
services.AddExtendedAttributesHandlers();
services.AddRazorPages();
services.AddApiVersioning(config =>
{
config.DefaultApiVersion = new ApiVersion(1, 0);
config.AssumeDefaultVersionWhenUnspecified = true;
config.ReportApiVersions = true;
});
services.AddLazyCache();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwarding(_configuration);
app.UseExceptionHandling(env);
app.UseHttpsRedirection();
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Files")),
RequestPath = new PathString("/Files")
});
app.UseRequestLocalizationByCulture();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseHangfireDashboard("/jobs", new DashboardOptions
{
DashboardTitle = "BlazorHero Jobs",
Authorization = new[] { new HangfireAuthorizationFilter() }
});
app.UseEndpoints();
app.ConfigureSwagger();
app.Initialize(_configuration);
}
}
}