aboutsummaryrefslogtreecommitdiff
path: root/API/Startup.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-12 15:04:45 +0200
committertranstrike <transtrike@gmail.com>2020-12-12 15:04:45 +0200
commit8bd7295dc4694c1c0ed6fbc05d390223bfc4ef05 (patch)
tree380757557eb7ac15809e5f04d224c2e494a327fd /API/Startup.cs
parent29b2a82d7ef2613b3e56eba7ed959243a98ae92d (diff)
downloadDevHive-8bd7295dc4694c1c0ed6fbc05d390223bfc4ef05.tar
DevHive-8bd7295dc4694c1c0ed6fbc05d390223bfc4ef05.tar.gz
DevHive-8bd7295dc4694c1c0ed6fbc05d390223bfc4ef05.zip
Added Extensions Methods
Diffstat (limited to 'API/Startup.cs')
-rw-r--r--API/Startup.cs50
1 files changed, 14 insertions, 36 deletions
diff --git a/API/Startup.cs b/API/Startup.cs
index f373f7a..b3d0769 100644
--- a/API/Startup.cs
+++ b/API/Startup.cs
@@ -1,15 +1,11 @@
using System;
-using API.Database;
using AutoMapper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-using Microsoft.OpenApi.Models;
-using Data.Models.Classes;
+using API.Extensions;
namespace API
{
@@ -27,26 +23,9 @@ namespace API
{
services.AddControllers();
- services.AddDbContext<DevHiveContext>(options =>
- options.UseNpgsql(Configuration.GetConnectionString("DEV")))
- .AddAuthentication()
- .AddJwtBearer();
-
- services.AddIdentity<User, Roles>()
- .AddEntityFrameworkStores<DevHiveContext>();
- services.AddAuthentication();
-
- services.Configure<IdentityOptions>(options =>
- {
- options.User.RequireUniqueEmail = true;
-
- options.Password.RequiredLength = 5;
- });
-
- services.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new OpenApiInfo { Title = "API", Version = "v1" });
- });
+ services.DatabaseConfiguration(Configuration);
+ services.SwaggerConfiguration();
+ services.JWTConfiguration();
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
}
@@ -56,25 +35,24 @@ namespace API
{
if (env.IsDevelopment())
{
- //app.UseDeveloperExceptionPage();
- app.UseExceptionHandler("/api/Error"); //TESTING
- app.UseSwagger();
- app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"));
+ app.UseDeveloperExceptionPage();
+ //app.UseExceptionHandler("/api/HttpError");
+ app.UseSwaggerConfiguration();
}
else
{
- app.UseExceptionHandler("/Error");
+ app.UseExceptionHandler("/api/HttpError");
+ app.UseHsts();
}
- app.UseHttpsRedirection();
- app.UseRouting();
-
- app.UseAuthentication();
- app.UseAuthorization();
+ app.UseJWTConfiguration();
app.UseEndpoints(endpoints =>
{
- endpoints.MapControllers();
+ endpoints.MapControllerRoute(
+ name: "default",
+ pattern: "api/{controller}/{action}"
+ );
});
}
}