54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using DysonNetwork.Sphere;
 | |
| using DysonNetwork.Sphere.Startup;
 | |
| using Microsoft.EntityFrameworkCore;
 | |
| using tusdotnet.Stores;
 | |
| 
 | |
| var builder = WebApplication.CreateBuilder(args);
 | |
| 
 | |
| // Configure Kestrel and server options
 | |
| builder.ConfigureAppKestrel();
 | |
| 
 | |
| // Add metrics and telemetry
 | |
| builder.Services.AddAppMetrics();
 | |
| 
 | |
| // Add application services
 | |
| builder.Services.AddAppServices(builder.Configuration);
 | |
| builder.Services.AddAppRateLimiting();
 | |
| builder.Services.AddAppAuthentication();
 | |
| builder.Services.AddAppSwagger();
 | |
| 
 | |
| // Add gRPC services
 | |
| builder.Services.AddGrpc();
 | |
| 
 | |
| // Add file storage
 | |
| builder.Services.AddAppFileStorage(builder.Configuration);
 | |
| 
 | |
| // Add flush handlers and websocket handlers
 | |
| builder.Services.AddAppFlushHandlers();
 | |
| 
 | |
| // Add business services
 | |
| builder.Services.AddAppBusinessServices(builder.Configuration);
 | |
| 
 | |
| // Add scheduled jobs
 | |
| builder.Services.AddAppScheduledJobs();
 | |
| 
 | |
| var app = builder.Build();
 | |
| 
 | |
| // Run database migrations
 | |
| using (var scope = app.Services.CreateScope())
 | |
| {
 | |
|     var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
 | |
|     await db.Database.MigrateAsync();
 | |
| }
 | |
| 
 | |
| // Get the TusDiskStore instance
 | |
| var tusDiskStore = app.Services.GetRequiredService<TusDiskStore>();
 | |
| 
 | |
| // Configure application middleware pipeline
 | |
| app.ConfigureAppMiddleware(builder.Configuration, tusDiskStore);
 | |
| 
 | |
| // Map gRPC services
 | |
| app.MapGrpcService<DysonNetwork.Sphere.Auth.AuthGrpcService>();
 | |
| app.MapGrpcService<DysonNetwork.Sphere.Account.AccountGrpcService>();
 | |
| 
 | |
| app.Run(); |