42 lines
1.3 KiB
C#

using HackerNet.Application;
using HackerNet.Domain;
using HackerNet.Infrastructure.Repositories.Memory;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var link = new Link("https://localhost:7050/", "Youhouuu");
var comment = new Comment(link.Id, "Wow!");
var linksRepository = new MemoryLinkRepository(link);
var commentsRepository = new MemoryCommentRepository(comment);
builder.Services.AddSingleton<ILinkRepository>(linksRepository);
builder.Services.AddSingleton<ICommentRepository>(commentsRepository);
builder.Services.AddSingleton<IReadStore>(new MemoryReadStore(linksRepository, commentsRepository));
builder.Services.AddSingleton<LinkService>();
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Links}/{action=Index}/{id?}");
app.Run();