Skip to content

Commit

Permalink
Register the Middleware and organize the commends using regions
Browse files Browse the repository at this point in the history
  • Loading branch information
nixhantb committed Mar 13, 2024
1 parent b6786a0 commit 53ac1da
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions JobLeet.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
using Microsoft.EntityFrameworkCore;
using JobLeet.WebApi.JobLeet.Infrastructure.Data.Contexts;
using JobLeet.WebApi.JobLeet.Api.Logging;
using JobLeet.WebApi.JobLeet.Api.Exceptions.CustomExceptionWrappers.V1;
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Configuration
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true);

#region Register the repository services
// Add the required Configurations
// Register the Repository service
builder.Services.AddControllers();
Expand All @@ -22,12 +24,16 @@
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
#endregion


#region Database configuration Services

builder.Services.AddDbContext<BaseDBContext>(options => {
options.UseMySql(builder.Configuration.GetConnectionString("jobleetconnect"), ServerVersion.AutoDetect(builder.Configuration.GetConnectionString("jobleetconnect")));
});
#endregion

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand All @@ -43,4 +49,8 @@

app.MapControllers();

#region Middleware Configurations
app.UseMiddleware<ResourceNotFoundException>();
#endregion

app.Run();

0 comments on commit 53ac1da

Please sign in to comment.