2019-07-11 15:03:17 -04:00
|
|
|
|
using System.Globalization;
|
2019-07-11 16:19:38 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.SharedWeb.Utilities;
|
2019-03-02 12:15:28 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.EventsProcessor;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2019-03-02 12:15:28 -05:00
|
|
|
|
public class Startup
|
|
|
|
|
|
{
|
|
|
|
|
|
public Startup(IWebHostEnvironment env, IConfiguration configuration)
|
|
|
|
|
|
{
|
2019-07-11 15:03:17 -04:00
|
|
|
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
2019-03-02 12:15:28 -05:00
|
|
|
|
Configuration = configuration;
|
|
|
|
|
|
Environment = env;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
2020-01-10 08:33:13 -05:00
|
|
|
|
public IWebHostEnvironment Environment { get; set; }
|
2019-03-02 12:15:28 -05:00
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
|
{
|
2019-07-11 21:45:14 -04:00
|
|
|
|
// Options
|
2019-03-02 12:15:28 -05:00
|
|
|
|
services.AddOptions();
|
2019-07-11 21:45:14 -04:00
|
|
|
|
|
|
|
|
|
|
// Settings
|
2025-02-11 10:20:06 -05:00
|
|
|
|
var globalSettings = services.AddGlobalSettingsServices(Configuration, Environment);
|
2019-07-11 21:45:14 -04:00
|
|
|
|
|
2025-04-23 10:44:43 -04:00
|
|
|
|
// Data Protection
|
|
|
|
|
|
services.AddCustomDataProtectionServices(Environment, globalSettings);
|
|
|
|
|
|
|
|
|
|
|
|
// Repositories
|
|
|
|
|
|
services.AddDatabaseRepositories(globalSettings);
|
2026-01-13 18:10:01 +01:00
|
|
|
|
services.AddTestPlayIdTracking(globalSettings);
|
2025-04-23 10:44:43 -04:00
|
|
|
|
|
2025-12-12 16:17:43 -05:00
|
|
|
|
// Add event integration services
|
|
|
|
|
|
services.AddDistributedCache(globalSettings);
|
2025-05-27 08:28:50 -04:00
|
|
|
|
services.AddAzureServiceBusListeners(globalSettings);
|
2019-03-02 12:15:28 -05:00
|
|
|
|
services.AddHostedService<AzureQueueHostedService>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-21 14:39:26 -05:00
|
|
|
|
public void Configure(IApplicationBuilder app)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-11-09 11:37:14 -05:00
|
|
|
|
// Add general security headers
|
|
|
|
|
|
app.UseMiddleware<SecurityHeadersMiddleware>();
|
2020-01-10 08:33:13 -05:00
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
2019-03-02 12:15:28 -05:00
|
|
|
|
{
|
2020-01-10 08:33:13 -05:00
|
|
|
|
endpoints.MapGet("/alive",
|
2021-12-09 15:45:45 -05:00
|
|
|
|
async context => await context.Response.WriteAsJsonAsync(System.DateTime.UtcNow));
|
|
|
|
|
|
endpoints.MapGet("/now",
|
|
|
|
|
|
async context => await context.Response.WriteAsJsonAsync(System.DateTime.UtcNow));
|
|
|
|
|
|
endpoints.MapGet("/version",
|
2022-09-05 11:19:04 -04:00
|
|
|
|
async context => await context.Response.WriteAsJsonAsync(AssemblyHelpers.GetVersion()));
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2020-01-10 08:33:13 -05:00
|
|
|
|
});
|
2019-03-02 12:15:28 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|