62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using JellyGlass.Repositories;
|
|
using JellyGlass.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
builder.Services.AddOpenApi();
|
|
builder.Services.AddControllers();
|
|
|
|
builder.Configuration.GetSection("TestingLogin");
|
|
|
|
string dbConnectionString;
|
|
|
|
if (builder.Environment.IsDevelopment())
|
|
{
|
|
dbConnectionString = "Data Source=JellyGlass-test.db;";
|
|
}
|
|
else
|
|
{
|
|
dbConnectionString = "Data Source=JellyGlass.db;";
|
|
}
|
|
|
|
builder.Services.AddSqlite<DatabaseContext>(dbConnectionString);
|
|
|
|
builder.Services.AddTransient<ILibraryService, LibraryService>();
|
|
builder.Services.AddTransient<IServerRepository, ServerRepository>();
|
|
builder.Services.AddScoped<IClientService, ClientService>();
|
|
builder.Services.AddTransient<IServerService, ServerService>();
|
|
builder.Services.AddTransient<ISearchService, SearchService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var dbContext = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
|
dbContext.Database.Migrate();
|
|
|
|
dbContext.Servers.Add(new JellyGlass.Models.Server()
|
|
{
|
|
ApiToken = "56b6f91b816540b59d03a0db53c2dc8e",
|
|
Id = "1",
|
|
Owner = "Riley",
|
|
Url = "https://jellyfin.foxhawk.co.uk"
|
|
});
|
|
|
|
dbContext.SaveChanges();
|
|
}
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.MapControllers();
|
|
app.UseDefaultFiles();
|
|
app.UseStaticFiles();
|
|
|
|
app.Run();
|