47 lines
1001 B
C#
47 lines
1001 B
C#
using Diary.Data;
|
|
using Diary.Installers;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
//GetConfigStuff
|
|
IConfigurationRoot config = new ConfigurationBuilder()
|
|
.AddJsonFile("appsettings.json",false)
|
|
.Build();
|
|
|
|
|
|
builder.Services.AddDatabase(config);
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddScoped<IDiaryDBContext, DiaryDBContext>();
|
|
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI(opt =>
|
|
{
|
|
opt.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
|
|
opt.RoutePrefix = String.Empty;
|
|
}
|
|
);
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run(); |