Skip to content

Instantly share code, notes, and snippets.

@theilgaz
Created March 17, 2022 14:20
Show Gist options
  • Save theilgaz/f369b7c33059981bd209db79aa3e6467 to your computer and use it in GitHub Desktop.
Save theilgaz/f369b7c33059981bd209db79aa3e6467 to your computer and use it in GitHub Desktop.
namespace API.Extensions
{
public static class ApplicationServiceExtensions
{
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config)
{
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebAPIv5", Version = "v1" });
});
services.AddDbContext<DataContext>(opt =>
{
opt.UseSqlite(config.GetConnectionString("DefaultConnection"));
});
services.AddCors(opt =>
{
opt.AddPolicy("CorsPolicy", policy =>
{
policy.WithHeaders("Access-Control-Allow-Origin: *");
});
});
services.AddMediatR(typeof(List.Handler).Assembly);
services.AddAutoMapper(typeof(MappingProfiles).Assembly);
return services;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment