chore: add launchSettings.json to make development not suck

This workflow allows the possibility to reload a changed page without reloading the entire app. I hate launchSettings.json, but whatever.
This commit is contained in:
Oliver Booth 2024-05-05 21:10:23 +01:00
parent 83beffe685
commit 23d3950695
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
4 changed files with 36 additions and 5 deletions

View File

@ -33,7 +33,6 @@
<PackageReference Include="MailKit" Version="4.4.0"/> <PackageReference Include="MailKit" Version="4.4.0"/>
<PackageReference Include="MailKitSimplified.Sender" Version="2.9.0"/> <PackageReference Include="MailKitSimplified.Sender" Version="2.9.0"/>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.3"/> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.3"/>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.3"/> <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.3"/>
<PackageReference Include="NetBarcode" Version="1.7.0"/> <PackageReference Include="NetBarcode" Version="1.7.0"/>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>

View File

@ -69,7 +69,7 @@ builder.Services.AddSingleton<IProjectService, ProjectService>();
builder.Services.AddSingleton<IMastodonService, MastodonService>(); builder.Services.AddSingleton<IMastodonService, MastodonService>();
builder.Services.AddSingleton<ITutorialService, TutorialService>(); builder.Services.AddSingleton<ITutorialService, TutorialService>();
builder.Services.AddSingleton<IReadingListService, ReadingListService>(); builder.Services.AddSingleton<IReadingListService, ReadingListService>();
builder.Services.AddRazorPages().AddRazorRuntimeCompilation(); builder.Services.AddRazorPages();
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
builder.Services.AddRouting(options => options.LowercaseUrls = true); builder.Services.AddRouting(options => options.LowercaseUrls = true);
builder.Services.AddReCaptcha(builder.Configuration.GetSection("ReCaptcha")); builder.Services.AddReCaptcha(builder.Configuration.GetSection("ReCaptcha"));

View File

@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5000",
"sslPort": 2845
}
},
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"workingDirectory": "bin/Debug/net8.0/",
"applicationUrl": "https://localhost:2845",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -15,18 +15,20 @@ internal sealed class MastodonService : IMastodonService
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
}; };
private readonly IConfiguration _configuration;
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
public MastodonService(HttpClient httpClient) public MastodonService(IConfiguration configuration, HttpClient httpClient)
{ {
_configuration = configuration;
_httpClient = httpClient; _httpClient = httpClient;
} }
/// <inheritdoc /> /// <inheritdoc />
public IMastodonStatus GetLatestStatus() public IMastodonStatus GetLatestStatus()
{ {
string token = Environment.GetEnvironmentVariable("MASTODON_TOKEN") ?? string.Empty; string token = _configuration.GetSection("Mastodon:Token").Value ?? string.Empty;
string account = Environment.GetEnvironmentVariable("MASTODON_ACCOUNT") ?? string.Empty; string account = _configuration.GetSection("Mastodon:Account").Value ?? string.Empty;
using var request = new HttpRequestMessage(); using var request = new HttpRequestMessage();
request.Headers.Add("Authorization", $"Bearer {token}"); request.Headers.Add("Authorization", $"Bearer {token}");
request.RequestUri = new Uri($"https://mastodon.olivr.me/api/v1/accounts/{account}/statuses"); request.RequestUri = new Uri($"https://mastodon.olivr.me/api/v1/accounts/{account}/statuses");