|
|
@ -39,19 +39,6 @@ namespace Server { |
|
|
|
services.AddSingleton<IDatabase, Database>(); |
|
|
|
services.AddSingleton<IDatabase, Database>(); |
|
|
|
services.AddSingleton(NodaTime.DateTimeZoneProviders.Tzdb); |
|
|
|
services.AddSingleton(NodaTime.DateTimeZoneProviders.Tzdb); |
|
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IFileStorage>((serviceProvider) => { |
|
|
|
|
|
|
|
var conf = serviceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
|
|
|
|
var section = conf.GetSection("FileStorage"); |
|
|
|
|
|
|
|
switch (section["Type"]) { |
|
|
|
|
|
|
|
case "local": { |
|
|
|
|
|
|
|
var dir = section["Directory"]; |
|
|
|
|
|
|
|
return new LocalFileStorage(dir!); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new Exception("Unable to configure FileStorage"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddControllers() |
|
|
|
services.AddControllers() |
|
|
|
.AddNewtonsoftJson(options => { |
|
|
|
.AddNewtonsoftJson(options => { |
|
|
|
options.SerializerSettings.ContractResolver = new DefaultContractResolver { |
|
|
|
options.SerializerSettings.ContractResolver = new DefaultContractResolver { |
|
|
|