init
This commit is contained in:
commit
ab2e20f7e1
72 changed files with 2000 additions and 0 deletions
39
Femto.Api/Program.cs
Normal file
39
Femto.Api/Program.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Femto.Modules.Blog;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var databaseConnectionString = builder.Configuration.GetConnectionString("Database");
|
||||
if (databaseConnectionString is null)
|
||||
throw new Exception("no database connection string found");
|
||||
|
||||
builder.Services.UseBlogModule(databaseConnectionString);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder
|
||||
.Services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
||||
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.Run();
|
Loading…
Add table
Add a link
Reference in a new issue