-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from lreb/releases/5.0.0-preview
Releases/5.0.0 preview -api working in net 5
- Loading branch information
Showing
102 changed files
with
3,577 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Facware.Api.Extensions | ||
{ | ||
/// <summary> | ||
/// Extension to setup CORS configuration | ||
/// </summary> | ||
public static class CorsExtension | ||
{ | ||
/// <summary> | ||
/// Policy cors name | ||
/// </summary> | ||
public static readonly string AllowSpecificOrigins = "AllowSpecificOrigins"; | ||
|
||
/// <summary> | ||
/// CORS configurations | ||
/// </summary> | ||
/// <param name="services">application service <see cref="IServiceCollection"/></param> | ||
/// <param name="configuration">app settings configuration <see cref="IConfiguration"/></param> | ||
public static void ConfigureCors(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddCors(options => | ||
{ | ||
options.AddPolicy(AllowSpecificOrigins, | ||
builder => | ||
{ | ||
builder.WithOrigins(configuration.GetSection("Cors:AllowedOrigin").Get<string[]>()) | ||
.AllowAnyHeader() | ||
.AllowAnyMethod() | ||
.AllowCredentials(); | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Facware.Data.Access; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Facware.Api.Extensions | ||
{ | ||
/// <summary> | ||
/// The Service Collection Extensions | ||
/// </summary> | ||
/// <seealso cref="IServiceCollection"/> | ||
public static class DatabaseExtension | ||
{ | ||
/// <summary> | ||
/// Set up the Service PostgreSQL DB Context | ||
/// </summary> | ||
/// <param name="services">The <see cref="IServiceCollection"/></param> | ||
/// <param name="configuration">app settings configuration <see cref="IConfiguration"/></param> | ||
public static void UsePostgreSqlServer(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
// https://www.npgsql.org/efcore/api/Microsoft.Extensions.DependencyInjection.NpgsqlServiceCollectionExtensions.html#Microsoft_Extensions_DependencyInjection_NpgsqlServiceCollectionExtensions_AddEntityFrameworkNpgsql_IServiceCollection_ | ||
// https://www.npgsql.org/efcore/index.html#additional-configuration-for-aspnet-core-applications | ||
|
||
services.AddDbContext<FacwareDbContext>(options => | ||
options.UseNpgsql( | ||
configuration["DbContextSettings:ConnectionString"], | ||
x => x.MigrationsAssembly("Facware.Data.Access"))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
namespace Facware.Api.Extensions | ||
{ | ||
public class DependencyInjectionExtension | ||
{ | ||
public DependencyInjectionExtension() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace Facware.Api.Extensions | ||
{ | ||
/// <summary> | ||
/// Custom environments extension | ||
/// </summary> | ||
public static class HostingEnvironmentExtension | ||
{ | ||
/// <summary> | ||
/// Quality assurance environment | ||
/// </summary> | ||
private const string QualityAssurance = "QualityAssurance"; | ||
/// <summary> | ||
/// Local environment | ||
/// </summary> | ||
private const string Local = "Local"; | ||
|
||
/// <summary> | ||
/// Checks if the current host environment name is quality assurance. | ||
/// </summary> | ||
/// <param name="hostingEnvironment">An instance of <see cref="IWebHostEnvironment"/>.</param> | ||
/// <returns>True if the environment name is quality assurance.</returns> | ||
public static bool IsQA(this IWebHostEnvironment hostingEnvironment) | ||
{ | ||
return hostingEnvironment.IsEnvironment(QualityAssurance); | ||
} | ||
|
||
/// <summary> | ||
/// Checks if the current host environment name is Local. | ||
/// </summary> | ||
/// <param name="hostingEnvironment">An instance of <see cref="IWebHostEnvironment"/>.</param> | ||
/// <returns>True if the environment name is local</returns> | ||
public static bool IsLocal(this IWebHostEnvironment hostingEnvironment) | ||
{ | ||
return hostingEnvironment.IsEnvironment(Local); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.OpenApi.Models; | ||
|
||
namespace Facware.Api.Extensions | ||
{ | ||
/// <summary> | ||
/// Swagger extension | ||
/// </summary> | ||
public static class SwaggerExtension | ||
{ | ||
#region Swagger Configuration | ||
/// <summary> | ||
/// Method to configure the Swagger Services within the Application services interface | ||
/// </summary> | ||
/// <param name="services">The Service Collection <see cref="IServiceCollection"/></param> | ||
/// <param name="config">The Service Collection <see cref="IConfiguration"/></param> | ||
public static void ConfigureSwaggerExtension(this IServiceCollection services, IConfiguration config) | ||
{ | ||
services.AddSwaggerGen(c => | ||
{ | ||
c.SwaggerDoc("v1", new OpenApiInfo | ||
{ | ||
Title = config["SwaggerConfiguration:Title"], | ||
Version = config["SwaggerConfiguration:Version"], | ||
Description = config["SwaggerConfiguration:Description"] | ||
}); | ||
|
||
// Set the comments path for the Swagger JSON and UI. | ||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; | ||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); | ||
|
||
c.IncludeXmlComments(xmlPath); | ||
}); | ||
} | ||
#endregion | ||
|
||
/// <summary> | ||
/// Enable Swagger pipeline | ||
/// </summary> | ||
/// <param name="app">application configuration <see cref="IApplicationBuilder"/></param> | ||
/// <param name="config">application settings <see cref="IConfiguration"/></param> | ||
public static void EnableSwaggerPipeline(this IApplicationBuilder app, IConfiguration config) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(option => | ||
{ | ||
option.SwaggerEndpoint( | ||
config["SwaggerConfiguration:SwaggerJSONEndpoints"], | ||
$"{config["SwaggerConfiguration:Title"]} {config["SwaggerConfiguration:Version"]}"); | ||
// To serve the Swagger UI at the apps root | ||
option.RoutePrefix = string.Empty; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"DbContextSettings": { | ||
"ConnectionString": "Server=127.0.0.1;Port=5432;Database=facware;User Id=postgres;Password=postgres;" | ||
}, | ||
"Cors": { | ||
"AllowedOrigin": [ | ||
"http://localhost:4200", | ||
"http://localhost:4201", | ||
"http://localhost:4202" | ||
] | ||
}, | ||
"SwaggerConfiguration": { | ||
"SwaggerJSONEndpoints": "swagger/v1/swagger.json", | ||
"Title": "Facware Base", | ||
"Version": "V1.0", | ||
"Description": "Facware base project.", | ||
"TermsOfService": "https://luisespinoza.facware.com/", | ||
"ContactName": "luis.espinoza@afacware.com respinozabarboza@gmail.com", | ||
"ContactEmail": "luis.espinoza@afacware.com respinozabarboza@gmail.com", | ||
"LicenseName": "MIT", | ||
"LicenseUrl": "https://opensource.org/licenses/MIT" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"DbContextSettings": { | ||
"ConnectionString": "Server=127.0.0.1;Port=5432;Database=facware;User Id=postgres;Password=postgres;" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"DbContextSettings": { | ||
"ConnectionString": "Server=127.0.0.1;Port=5432;Database=facware;User Id=postgres;Password=postgres;" | ||
} | ||
} |
Oops, something went wrong.