diff --git a/JOBot.Backend/DAL/Context/AppDbContext.cs b/JOBot.Backend/DAL/Context/AppDbContext.cs index a8d79bb..730c478 100644 --- a/JOBot.Backend/DAL/Context/AppDbContext.cs +++ b/JOBot.Backend/DAL/Context/AppDbContext.cs @@ -3,7 +3,7 @@ namespace JOBot.Backend.DAL.Context; using JOBot.Backend.DAL.Models; using Microsoft.EntityFrameworkCore; -class AppDbContext : DbContext +public class AppDbContext : DbContext { public DbSet Users { get; set; } diff --git a/JOBot.Backend/Program.cs b/JOBot.Backend/Program.cs index 35e3e07..a91fc1d 100644 --- a/JOBot.Backend/Program.cs +++ b/JOBot.Backend/Program.cs @@ -1,16 +1,9 @@ -using JOBot.Backend.DAL.Context; -using JOBot.Backend.Services.gRPC; -using Microsoft.EntityFrameworkCore; - var builder = WebApplication.CreateBuilder(args); -builder.Services.AddGrpc(); -builder.Services.AddDbContext(options => - options.UseNpgsql(builder.Configuration.GetConnectionString("PostgreSQL"))); - +var startup = new Startup(builder.Configuration); +startup.ConfigureServices(builder.Services); var app = builder.Build(); - -app.MapGrpcService(); +startup.Configure(app, app.Environment); app.Run(); \ No newline at end of file diff --git a/JOBot.Backend/Services/gRPC/UserService.cs b/JOBot.Backend/Services/gRPC/UserService.cs index c265578..243882c 100644 --- a/JOBot.Backend/Services/gRPC/UserService.cs +++ b/JOBot.Backend/Services/gRPC/UserService.cs @@ -1,4 +1,3 @@ - using Grpc.Core; using JOBot.Proto; using JOBot.Backend.DAL.Context; @@ -6,7 +5,7 @@ using JOBot.Backend.DAL.Context; using Models = JOBot.Backend.DAL.Models; namespace JOBot.Backend.Services.gRPC; -class UserService(AppDbContext dbContext) : User.UserBase +public class UserService(AppDbContext dbContext) : User.UserBase { public override Task Register( diff --git a/JOBot.Backend/Startup.cs b/JOBot.Backend/Startup.cs new file mode 100644 index 0000000..a1b0a0c --- /dev/null +++ b/JOBot.Backend/Startup.cs @@ -0,0 +1,25 @@ +using JOBot.Backend.DAL.Context; +using JOBot.Backend.Services.gRPC; +using Microsoft.EntityFrameworkCore; + +public class Startup +{ + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddGrpc(); + services.AddDbContext(options => + options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL"))); + } + + public void Configure(WebApplication app, IWebHostEnvironment env) + { + app.MapGrpcService(); + } +} \ No newline at end of file diff --git a/JOBot.Backend/appsettings.Staging.json b/JOBot.Backend/appsettings.Staging.json new file mode 100644 index 0000000..2a11f60 --- /dev/null +++ b/JOBot.Backend/appsettings.Staging.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "PostgreSQL": "Host=localhost;Port=5432;Database=jobot_test;Username=postgres;Password=LocalDbPass" + } +} \ No newline at end of file