Add initial project structure and implement basic functionality
- Created MSTestSettings.cs to enable parallel test execution. - Added StyleTests.cs and TitreTests.cs for unit testing of Style and Titre entities. - Implemented Webzine.Entity.Tests project with necessary configurations. - Created SeedDataLocal.cs and SeedDataSpotify.cs for local and Spotify data seeding. - Established repository contracts for Artiste, Commentaire, Style, and Titre. - Developed DbEntityRepository and LocalEntityRepository classes. - Set up Webzine.WebApplication with controllers, logging, and Docker support. - Configured NLog for logging and added necessary appsettings for development. - Created initial views and layout for the web application. - Added Dockerfile and docker-compose configuration for containerization.
This commit is contained in:
27
Webzine.WebApplication/Controllers/api/VersionController.cs
Normal file
27
Webzine.WebApplication/Controllers/api/VersionController.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Webzine.WebApplication.Controllers.api;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class VersionController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<VersionController> _logger;
|
||||
|
||||
public VersionController(ILogger<VersionController> logger)
|
||||
{
|
||||
this._logger = logger;
|
||||
this._logger.LogDebug(1, "NLog injected into VersionController");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Get()
|
||||
{
|
||||
this._logger.LogInformation("Get Version was called");
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
nom = "webzine",
|
||||
version = "1.0",
|
||||
});
|
||||
}
|
||||
}
|
||||
23
Webzine.WebApplication/Dockerfile
Normal file
23
Webzine.WebApplication/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Webzine.WebApplication/Webzine.WebApplication.csproj", "Webzine.WebApplication/"]
|
||||
RUN dotnet restore "Webzine.WebApplication/Webzine.WebApplication.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Webzine.WebApplication"
|
||||
RUN dotnet build "./Webzine.WebApplication.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Webzine.WebApplication.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Webzine.WebApplication.dll"]
|
||||
52
Webzine.WebApplication/Program.cs
Normal file
52
Webzine.WebApplication/Program.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
|
||||
// Early init of NLog to allow startup and exception logging, before host is built
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Debug("init main");
|
||||
|
||||
try
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Ajoute les services n<>cessaires pour permettre l'utilisation des
|
||||
// controllers avec des vues.
|
||||
builder.Services.AddControllersWithViews()
|
||||
// Ajoute la compilation des vues lors de l'ex<65>cution de l'application.
|
||||
// Cela nous <20>vite de recompiler l'application <20> chaque modification de vue.
|
||||
// N<>cessite le package Nuget Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.
|
||||
.AddRazorRuntimeCompilation();
|
||||
|
||||
// NLog: Setup NLog for Dependency injection
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Host.UseNLog();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Active la possibilit<69> de servir des fichiers statiques pr<70>sents dans
|
||||
// le dossier wwwroot.
|
||||
app.UseStaticFiles();
|
||||
|
||||
// Active le middleware permettant le routage des requ<71>tes entrantes.
|
||||
app.UseRouting();
|
||||
|
||||
// Ajoute un endpoint permettant de router les urls
|
||||
// avec la forme /controller/action/id(optionnel).
|
||||
// Equivalent <20> app.MapDefaultControllerRoute()
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// NLog: catch setup errors
|
||||
logger.Error(exception, "Stopped program because of exception");
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
||||
NLog.LogManager.Shutdown();
|
||||
}
|
||||
23
Webzine.WebApplication/Properties/launchSettings.json
Normal file
23
Webzine.WebApplication/Properties/launchSettings.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5038",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7095;http://localhost:5038",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Webzine.WebApplication/Views/Shared/_Layout.cshtml
Normal file
15
Webzine.WebApplication/Views/Shared/_Layout.cshtml
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>@ViewData["Title"] - Mon Application</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
@RenderBody()
|
||||
</main>
|
||||
</body>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
||||
</html>
|
||||
2
Webzine.WebApplication/Views/_ViewImports.cshtml
Normal file
2
Webzine.WebApplication/Views/_ViewImports.cshtml
Normal file
@@ -0,0 +1,2 @@
|
||||
@* Permet de factoriser les imports de tag helpers *@
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
3
Webzine.WebApplication/Views/_ViewStart.cshtml
Normal file
3
Webzine.WebApplication/Views/_ViewStart.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
36
Webzine.WebApplication/Webzine.WebApplication.csproj
Normal file
36
Webzine.WebApplication/Webzine.WebApplication.csproj
Normal file
@@ -0,0 +1,36 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\.dockerignore">
|
||||
<Link>.dockerignore</Link>
|
||||
</Content>
|
||||
<Content Include="..\Webzine.Documentation\StyleCop\stylecop.json">
|
||||
<Link>stylecop.json</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\data\" />
|
||||
<Folder Include="wwwroot\js\" />
|
||||
<Folder Include="wwwroot\lib\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="10.0.3" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.*" />
|
||||
<PackageReference Include="NLog" Version="5.*" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
8
Webzine.WebApplication/appsettings.Development.json
Normal file
8
Webzine.WebApplication/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Webzine.WebApplication/appsettings.json
Normal file
9
Webzine.WebApplication/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
40
Webzine.WebApplication/nlog.config
Normal file
40
Webzine.WebApplication/nlog.config
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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"
|
||||
autoReload="true"
|
||||
throwConfigExceptions="true"
|
||||
internalLogLevel="Info"
|
||||
internalLogFile="/Logs/internal-nlog-AspNetCore.txt">
|
||||
|
||||
<extensions>
|
||||
<add assembly="NLog.Web.AspNetCore"/>
|
||||
</extensions>
|
||||
|
||||
<targets>
|
||||
<!-- Journalisation complète -->
|
||||
<target xsi:type="File" name="allfile"
|
||||
fileName="/Logs/nlog-all-${shortdate}.log"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}" />
|
||||
|
||||
<!-- Journalisation spécifique avec détails web -->
|
||||
<target xsi:type="File" name="ownfile-web"
|
||||
fileName="/Logs/nlog-own-${shortdate}.log"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}|${aspnet-request-url:whenEmpty=NoRequest}" />
|
||||
|
||||
<!-- Console pour debug immédiat -->
|
||||
<target xsi:type="Console" name="console"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<!-- Vos logs d'application en Debug+ -->
|
||||
<logger name="Webzine.WebApplication.*" minlevel="Debug" writeTo="allfile,ownfile-web,console" />
|
||||
|
||||
<!-- Logs Microsoft en Warning+ sauf Hosting.Lifetime -->
|
||||
<logger name="Microsoft.*" minlevel="Warn" writeTo="allfile" final="true" />
|
||||
<logger name="Microsoft.Hosting.Lifetime*" minlevel="Info" writeTo="allfile,console" final="true" />
|
||||
|
||||
<!-- Tous les autres logs (y compris System) en Info+ -->
|
||||
<logger name="*" minlevel="Info" writeTo="allfile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
0
Webzine.WebApplication/wwwroot/css/app.css
Normal file
0
Webzine.WebApplication/wwwroot/css/app.css
Normal file
0
Webzine.WebApplication/wwwroot/favicon.ico
Normal file
0
Webzine.WebApplication/wwwroot/favicon.ico
Normal file
0
Webzine.WebApplication/wwwroot/images/avater.png
Normal file
0
Webzine.WebApplication/wwwroot/images/avater.png
Normal file
0
Webzine.WebApplication/wwwroot/js/app.js
Normal file
0
Webzine.WebApplication/wwwroot/js/app.js
Normal file
Reference in New Issue
Block a user