summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Startup.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-07-19 16:07:31 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-09-14 18:53:15 -0400
commit7a2891573b746a316dd00243c22ccb9e3ed09004 (patch)
tree53bd4c4c1f1b7440e389fd1ed0fb42c286c345d5 /src/SMAPI.Web/Startup.cs
parentce6cedaf4be53d52f2e558055b91e515b92e4c83 (diff)
downloadSMAPI-7a2891573b746a316dd00243c22ccb9e3ed09004.tar.gz
SMAPI-7a2891573b746a316dd00243c22ccb9e3ed09004.tar.bz2
SMAPI-7a2891573b746a316dd00243c22ccb9e3ed09004.zip
minor cleanup (#651)
Diffstat (limited to 'src/SMAPI.Web/Startup.cs')
-rw-r--r--src/SMAPI.Web/Startup.cs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs
index bdfa5ed9..85b6ebe0 100644
--- a/src/SMAPI.Web/Startup.cs
+++ b/src/SMAPI.Web/Startup.cs
@@ -71,6 +71,7 @@ namespace StardewModdingAPI.Web
options.SerializerSettings.Formatting = Formatting.Indented;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
+ MongoDbConfig mongoConfig = this.Configuration.GetSection("MongoDB").Get<MongoDbConfig>();
// init background service
{
@@ -80,12 +81,10 @@ namespace StardewModdingAPI.Web
}
// init MongoDB
- MongoDbConfig mongoConfig = this.Configuration.GetSection("MongoDB").Get<MongoDbConfig>();
- string mongoConnectionStr = mongoConfig.GetConnectionString();
- services.AddSingleton<IMongoDatabase>(serv => new MongoClient(mongoConnectionStr).GetDatabase(mongoConfig.Database));
- services.AddSingleton<IWikiCacheRepository>(serv => new WikiCacheRepository(serv.GetService<IMongoDatabase>()));
+ services.AddSingleton<IMongoDatabase>(serv => new MongoClient(mongoConfig.GetConnectionString()).GetDatabase(mongoConfig.Database));
+ services.AddSingleton<IWikiCacheRepository>(serv => new WikiCacheRepository(serv.GetRequiredService<IMongoDatabase>()));
- // init Hangfire (needs MongoDB)
+ // init Hangfire
services
.AddHangfire(config =>
{
@@ -93,7 +92,7 @@ namespace StardewModdingAPI.Web
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
- .UseMongoStorage(mongoConnectionStr, $"{mongoConfig.Database}-hangfire", new MongoStorageOptions
+ .UseMongoStorage(mongoConfig.GetConnectionString(), $"{mongoConfig.Database}-hangfire", new MongoStorageOptions
{
MigrationOptions = new MongoMigrationOptions(MongoMigrationStrategy.Drop)
});