// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { RegisterHealthChecks(services, Configuration.GetConnectionString("DefaultConnection")); services.RegisterRepositoryServices(); //auto mapper start AutoMapperConfig.RegisterMappings(); services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.Configure <ImageSettings>(options => Configuration.GetSection("ImageSettings").Bind(options)); services.Configure <EmailSettings>(options => Configuration.GetSection("EmailSettings").Bind(options)); services.Configure <ServerSettings>(options => Configuration.GetSection("ServerSettings").Bind(options)); services.Configure <NotificationSettings>(options => Configuration.GetSection("NotificationSettings").Bind(options)); JWTConfig.RegisterJWT(services, Configuration); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "SHAREBOOK API", Version = "v1" }); c.ResolveConflictingActions(x => x.First()); c.AddSecurityDefinition("Bearer", new ApiKeyScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", In = "header", Type = "apiKey" }); c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > { { "Bearer", Enumerable.Empty <string>() }, }); }); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); RollbarConfigurator.Configure(Configuration.GetSection("RollbarEnvironment").Value); MuambatorConfigurator.Configure(Configuration.GetSection("Muambator:Token").Value, Configuration.GetSection("Muambator:IsActive").Value); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.RegisterRepositoryServices(); //auto mapper start AutoMapperConfig.RegisterMappings(); services.AddMvc(); services.Configure <EmailSettings>(options => Configuration.GetSection("EmailSettings").Bind(options)); JWTConfig.RegisterJWT(services, Configuration); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "SHAREBOOK API", Version = "v1" }); c.AddSecurityDefinition("Bearer", new ApiKeyScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", In = "header", Type = "apiKey" }); c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > { { "Bearer", Enumerable.Empty <string>() }, }); }); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); }
public void ConfigureServices(IServiceCollection services) { RegisterHealthChecks(services, Configuration.GetConnectionString("DefaultConnection")); services.RegisterRepositoryServices(); services.AddAutoMapper(typeof(Startup)); services .AddControllers() .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }).AddNewtonsoftJson(); services .AddHttpContextAccessor() .Configure <RollbarOptions>(options => Configuration.GetSection("Rollbar").Bind(options)) .AddRollbarLogger(loggerOptions => loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Trace); services.Configure <ImageSettings>(options => Configuration.GetSection("ImageSettings").Bind(options)); services.Configure <EmailSettings>(options => Configuration.GetSection("EmailSettings").Bind(options)); services.Configure <ServerSettings>(options => Configuration.GetSection("ServerSettings").Bind(options)); services.Configure <NotificationSettings>(options => Configuration.GetSection("NotificationSettings").Bind(options)); services.Configure <AWSSQSSettings>(options => Configuration.GetSection("AWSSQSSettings").Bind(options)); services.AddHttpContextAccessor(); JWTConfig.RegisterJWT(services, Configuration); services.RegisterSwagger(); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services .AddDbContext <ApplicationDbContext>(options => options .UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); RollbarConfigurator .Configure(environment: Configuration.GetSection("Rollbar:Environment").Value, isActive: Configuration.GetSection("Rollbar:IsActive").Value, token: Configuration.GetSection("Rollbar:Token").Value, logLevel: Configuration.GetSection("Rollbar:LogLevel").Value); MuambatorConfigurator.Configure(Configuration.GetSection("Muambator:Token").Value, Configuration.GetSection("Muambator:IsActive").Value); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.RegisterRepositoryServices(); //auto mapper start AutoMapperConfig.RegisterMappings(); services.AddMvc(); services.Configure <ImageSettings>(options => Configuration.GetSection("ImageSettings").Bind(options)); services.Configure <EmailSettings>(options => Configuration.GetSection("EmailSettings").Bind(options)); services.Configure <ServerSettings>(options => Configuration.GetSection("ServerSettings").Bind(options)); JWTConfig.RegisterJWT(services, Configuration); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "INDIQME API", Version = "v1" }); c.ResolveConflictingActions(x => x.First()); c.AddSecurityDefinition("Bearer", new ApiKeyScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", In = "header", Type = "apiKey" }); c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > { { "Bearer", Enumerable.Empty <string>() }, }); }); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); }
public void ConfigureServices(IServiceCollection services) { RegisterHealthChecks(services, Configuration.GetConnectionString("DefaultConnection")); services.RegisterRepositoryServices(); services.AddAutoMapper(typeof(Startup)); services .AddControllers() .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }).AddNewtonsoftJson(); services .AddHttpContextAccessor() .Configure <RollbarOptions>(options => Configuration.GetSection("Rollbar").Bind(options)) .AddRollbarLogger(loggerOptions => loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Trace); services.AddHttpContextAccessor(); JWTConfig.RegisterJWT(services, Configuration); services.RegisterSwagger(); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services .AddDbContext <ApplicationDbContext>(options => options .UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); }
public void ConfigureServices(IServiceCollection services) { var isDocker = Environment.GetEnvironmentVariable("IS_DOCKER"); var connectionStringKey = isDocker == "1" ? "DefaultConnectionDocker" : "DefaultConnection"; RegisterHealthChecks(services, Configuration.GetConnectionString(connectionStringKey)); services.RegisterRepositoryServices(); services.AddAutoMapper(typeof(Startup)); services .AddControllers(x => { x.Filters.Add(typeof(ValidateModelStateFilterAttribute)); }) .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }).AddNewtonsoftJson(); services.Configure <ApiBehaviorOptions>(options => { options.SuppressModelStateInvalidFilter = true; }); services.AddHttpContextAccessor(); services.Configure <ImageSettings>(options => Configuration.GetSection("ImageSettings").Bind(options)); services.Configure <EmailSettings>(options => Configuration.GetSection("EmailSettings").Bind(options)); services.Configure <ServerSettings>(options => Configuration.GetSection("ServerSettings").Bind(options)); services.Configure <NotificationSettings>(options => Configuration.GetSection("NotificationSettings").Bind(options)); services.Configure <AWSSQSSettings>(options => Configuration.GetSection("AWSSQSSettings").Bind(options)); services.AddHttpContextAccessor(); JWTConfig.RegisterJWT(services, Configuration); services.RegisterSwagger(); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services .AddDbContext <ApplicationDbContext>(options => options .UseSqlServer(Configuration.GetConnectionString(connectionStringKey))); RollbarConfigurator .Configure(environment: Configuration.GetSection("Rollbar:Environment").Value, isActive: Configuration.GetSection("Rollbar:IsActive").Value, token: Configuration.GetSection("Rollbar:Token").Value, logLevel: Configuration.GetSection("Rollbar:LogLevel").Value); services.AddRollbarLogger(); MuambatorConfigurator.Configure(Configuration.GetSection("Muambator:Token").Value, Configuration.GetSection("Muambator:IsActive").Value); services.AddMemoryCache(); }