Minor fixes
This commit is contained in:
48
.github/workflows/build.yml
vendored
Normal file
48
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: SonarCloud
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
jobs:
|
||||
build:
|
||||
name: Build and analyze
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: "zulu" # Alternative distribution options are available.
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~\sonar\cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
- name: Cache SonarCloud scanner
|
||||
id: cache-sonar-scanner
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: .\.sonar\scanner
|
||||
key: ${{ runner.os }}-sonar-scanner
|
||||
restore-keys: ${{ runner.os }}-sonar-scanner
|
||||
- name: Install SonarCloud scanner
|
||||
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
|
||||
shell: powershell
|
||||
run: |
|
||||
New-Item -Path .\.sonar\scanner -ItemType Directory
|
||||
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
|
||||
- name: Build and analyze
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
shell: powershell
|
||||
run: |
|
||||
.\.sonar\scanner\dotnet-sonarscanner begin /k:"csimonapastore_BasicDotnetTemplate" /o:"csimonapastore-github" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
|
||||
dotnet build
|
||||
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
@@ -21,7 +21,13 @@
|
||||
"ASPNETCORE_URLS": "https://localhost:5000;https://localhost:5001",
|
||||
"ASPNETCORE_DETAILEDERRORS": "1",
|
||||
"ASPNETCORE_SHUTDOWNTIMEOUTSECONDS": "3"
|
||||
}
|
||||
},
|
||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
|
||||
"uriFormat": "%s/swagger"
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
|
||||
9
Models/Settings/AppSettings.cs
Normal file
9
Models/Settings/AppSettings.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace BasicDotnetTemplate.Models.Settings;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
#nullable enable
|
||||
public Settings? Settings { get; set; }
|
||||
public PrivateSettings? PrivateSettings { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
10
Models/Settings/DatabaseConnection.cs
Normal file
10
Models/Settings/DatabaseConnection.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace BasicDotnetTemplate.Models.Settings;
|
||||
|
||||
public class DatabaseConnection
|
||||
{
|
||||
#nullable enable
|
||||
public string? SqlServer { get; set; }
|
||||
public string? Postgres { get; set; }
|
||||
public string? Mongodb { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
8
Models/Settings/PrivateSettings.cs
Normal file
8
Models/Settings/PrivateSettings.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace BasicDotnetTemplate.Models.Settings;
|
||||
|
||||
public class PrivateSettings
|
||||
{
|
||||
#nullable enable
|
||||
public DatabaseConnection? DatabaseConnection { get; set; }
|
||||
#nullable disable
|
||||
}
|
||||
14
NLog.config
Normal file
14
NLog.config
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<targets>
|
||||
<target name="logfile" xsi:type="File" fileName="file.txt" />
|
||||
<target name="logconsole" xsi:type="Console" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Info" writeTo="logconsole" />
|
||||
<logger name="*" minlevel="Debug" writeTo="logfile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
17
Program.cs
17
Program.cs
@@ -18,7 +18,11 @@ internal class Program
|
||||
// REGISTER SERVICES HERE
|
||||
builder.Services.AddSingleton<IConfiguration>(_configuration);
|
||||
|
||||
builder.Services.Configure<Settings>(_configuration.GetSection("Settings"));
|
||||
PrivateSettings privateSettings = new PrivateSettings();
|
||||
_configuration.GetSection("PrivateSettings").Bind(privateSettings);
|
||||
|
||||
builder.Services.Configure<AppSettings>(_configuration.GetSection("AppSettings"));
|
||||
builder.Services.Configure<PrivateSettings>(_configuration.GetSection("PrivateSettings"));
|
||||
|
||||
builder.Services.AddAuthentication();
|
||||
builder.Services.AddAuthorization();
|
||||
@@ -27,16 +31,17 @@ internal class Program
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
||||
Settings settings = new Settings();
|
||||
_configuration.GetSection("Settings").Bind(settings);
|
||||
AppSettings appSettings = new AppSettings();
|
||||
appSettings.PrivateSettings = privateSettings;
|
||||
_configuration.GetSection("AppSettings").Bind(appSettings);
|
||||
|
||||
builder.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Version = settings.Version,
|
||||
Title = settings.Name,
|
||||
Description = settings.Description,
|
||||
Version = appSettings?.Settings?.Version,
|
||||
Title = appSettings?.Settings?.Name,
|
||||
Description = appSettings?.Settings?.Description,
|
||||
TermsOfService = new Uri("https://example.com/terms"),
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{
|
||||
"AppSettings" :
|
||||
{
|
||||
"Settings": {
|
||||
"Name": "BasicDotnetTemplate",
|
||||
@@ -5,3 +7,5 @@
|
||||
"Description": "This template contains basic configuration for a .Net 8 backend"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
}
|
||||
|
||||
.topbar-wrapper .link:after {
|
||||
content: 'Unoffical McLaren F1 API';
|
||||
/* content: 'Unoffical McLaren F1 API'; */
|
||||
/* color: #fff; */
|
||||
visibility: visible;
|
||||
display: block;
|
||||
|
||||
Reference in New Issue
Block a user