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:
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();
|
||||
}
|
||||
Reference in New Issue
Block a user