aboutsummaryrefslogtreecommitdiff
path: root/src/Web/DevHive.Web/Startup.cs
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:51:35 +0300
committerGitHub <noreply@github.com>2021-04-09 19:51:35 +0300
commit233f38915ba0079079233eff55434ef349c05c45 (patch)
tree6c5f69017865bcab87355e910c87339453da1406 /src/Web/DevHive.Web/Startup.cs
parentf4a70c6430db923af9fa9958a11c2d6612cb52cc (diff)
parenta992357efcf1bc1ece81b95ecee5e05a0b73bfdc (diff)
downloadDevHive-233f38915ba0079079233eff55434ef349c05c45.tar
DevHive-233f38915ba0079079233eff55434ef349c05c45.tar.gz
DevHive-233f38915ba0079079233eff55434ef349c05c45.zip
Merge pull request #28 from Team-Kaleidoscope/devHEADv0.2mainheroku/main
Second stage: Complete
Diffstat (limited to 'src/Web/DevHive.Web/Startup.cs')
-rw-r--r--src/Web/DevHive.Web/Startup.cs75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/Web/DevHive.Web/Startup.cs b/src/Web/DevHive.Web/Startup.cs
new file mode 100644
index 0000000..49fa408
--- /dev/null
+++ b/src/Web/DevHive.Web/Startup.cs
@@ -0,0 +1,75 @@
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using DevHive.Web.Configurations.Extensions;
+using Newtonsoft.Json;
+using Serilog;
+
+namespace DevHive.Web
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddCors();
+
+ services.AddControllers()
+ .AddNewtonsoftJson(x =>
+ {
+ x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
+ });
+
+ services.DependencyInjectionConfiguration(this.Configuration);
+ services.DatabaseConfiguration(Configuration);
+ services.SwaggerConfiguration();
+ services.JWTConfiguration(Configuration);
+ services.AutoMapperConfiguration();
+ services.ConfigureExceptionHandler(this.Configuration);
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ app.UseCors(x => x
+ .AllowAnyMethod()
+ .AllowAnyHeader()
+ .SetIsOriginAllowed(origin => true) // allow any origin
+ .AllowCredentials()); // allow credentials
+
+ if (env.IsDevelopment())
+ {
+ app.UseExceptionHandlerMiddlewareConfiguration();
+ // app.UseDeveloperExceptionPage();
+ }
+ else
+ {
+ app.UseHsts();
+ app.UseExceptionHandlerMiddlewareConfiguration();
+ }
+
+ app.UseSwaggerConfiguration();
+ app.UseDatabaseConfiguration();
+ app.UseAutoMapperConfiguration();
+
+ app.UseSerilogRequestLogging();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "api/{controller}/{action}"
+ );
+ });
+ }
+ }
+}