42 lines
1018 B
C#
42 lines
1018 B
C#
using System.Text.Json.Serialization;
|
|
using gaseous_server;
|
|
using gaseous_tools;
|
|
|
|
// set up db
|
|
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
db.InitDB();
|
|
|
|
// set up server
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(x =>
|
|
{
|
|
// serialize enums as strings in api responses (e.g. Role)
|
|
x.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
|
});
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.AddHostedService<TimedHostedService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
// start the app
|
|
app.Run();
|
|
|