feat: added Startup class
This commit is contained in:
parent
ea0233905d
commit
f8f5acbd0e
@ -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<User> Users { get; set; }
|
||||
|
||||
|
@ -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<AppDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("PostgreSQL")));
|
||||
|
||||
var startup = new Startup(builder.Configuration);
|
||||
startup.ConfigureServices(builder.Services);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapGrpcService<UserService>();
|
||||
startup.Configure(app, app.Environment);
|
||||
|
||||
app.Run();
|
@ -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<RegisterResponse> Register(
|
||||
|
25
JOBot.Backend/Startup.cs
Normal file
25
JOBot.Backend/Startup.cs
Normal file
@ -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<AppDbContext>(options =>
|
||||
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
|
||||
}
|
||||
|
||||
public void Configure(WebApplication app, IWebHostEnvironment env)
|
||||
{
|
||||
app.MapGrpcService<UserService>();
|
||||
}
|
||||
}
|
12
JOBot.Backend/appsettings.Staging.json
Normal file
12
JOBot.Backend/appsettings.Staging.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user