Skip to content

Commit

Permalink
#218 - Fix connection string paths. Fix JwtOptions registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Mar 2, 2019
1 parent 03eef81 commit 67d7a10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
17 changes: 15 additions & 2 deletions src/Money.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,26 @@ namespace Money
public class Startup
{
public IConfiguration Configuration { get; }
public IHostingEnvironment Environment { get; }

public Startup(IConfiguration configuration) => Configuration = configuration;
public Startup(IConfiguration configuration, IHostingEnvironment environment)
{
Configuration = configuration;
Environment = environment;
}

public void ConfigureServices(IServiceCollection services)
{
ConnectionStrings connectionStrings = Configuration
.GetSection("ConnectionStrings")
.Get<ConnectionStrings>();

string ApplyBasePath(string value) => value.Replace("{BasePath}", Environment.ContentRootPath);

connectionStrings.Application = ApplyBasePath(connectionStrings.Application);
connectionStrings.EventSourcing = ApplyBasePath(connectionStrings.EventSourcing);
connectionStrings.ReadModel = ApplyBasePath(connectionStrings.ReadModel);

services
.AddDbContext<ApplicationDbContext>(options => options.UseSqlite(connectionStrings.Application));

Expand Down Expand Up @@ -71,7 +82,9 @@ public void ConfigureServices(IServiceCollection services)
.AddRouting(options => options.LowercaseUrls = true)
.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

services.AddTransient<JwtSecurityTokenHandler>();
services
.AddTransient<JwtSecurityTokenHandler>()
.Configure<JwtOptions>(Configuration.GetSection("Jwt"));
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down
6 changes: 3 additions & 3 deletions src/Money.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"ExpiryInDays": 14
},
"ConnectionStrings": {
"Application": "Filename=data/Application.db",
"EventSourcing": "Filename=data/EventSourcing.db",
"ReadModel": "Filename=data/ReadModel.db"
"Application": "Filename={BasePath}/data/Application.db",
"EventSourcing": "Filename={BasePath}/data/EventSourcing.db",
"ReadModel": "Filename={BasePath}/data/ReadModel.db"
}
}

0 comments on commit 67d7a10

Please sign in to comment.