36 lines
1013 B
C#
36 lines
1013 B
C#
using DysonNetwork.Pass;
|
|
using DysonNetwork.Pass.Account;
|
|
using DysonNetwork.Pass.Auth;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddGrpc();
|
|
builder.Services.AddDbContext<AppDatabase>(options =>
|
|
options.UseNpgsql(builder.Configuration.GetConnectionString("App")));
|
|
|
|
builder.Services.AddScoped<AccountService>();
|
|
builder.Services.AddScoped<AuthService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
app.MapGrpcService<AccountGrpcService>();
|
|
app.MapGrpcService<AuthGrpcService>();
|
|
|
|
// Run database migrations
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
|
|
await db.Database.MigrateAsync();
|
|
}
|
|
|
|
app.Run(); |