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 JOBot.Backend.DAL.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
class AppDbContext : DbContext
|
public class AppDbContext : DbContext
|
||||||
{
|
{
|
||||||
public DbSet<User> Users { get; set; }
|
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);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddGrpc();
|
var startup = new Startup(builder.Configuration);
|
||||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
startup.ConfigureServices(builder.Services);
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString("PostgreSQL")));
|
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
startup.Configure(app, app.Environment);
|
||||||
app.MapGrpcService<UserService>();
|
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using JOBot.Proto;
|
using JOBot.Proto;
|
||||||
using JOBot.Backend.DAL.Context;
|
using JOBot.Backend.DAL.Context;
|
||||||
@ -6,7 +5,7 @@ using JOBot.Backend.DAL.Context;
|
|||||||
using Models = JOBot.Backend.DAL.Models;
|
using Models = JOBot.Backend.DAL.Models;
|
||||||
|
|
||||||
namespace JOBot.Backend.Services.gRPC;
|
namespace JOBot.Backend.Services.gRPC;
|
||||||
class UserService(AppDbContext dbContext) : User.UserBase
|
public class UserService(AppDbContext dbContext) : User.UserBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public override Task<RegisterResponse> Register(
|
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