Adds messages api
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
using Azure.Identity;
|
||||
using FastEndpoints;
|
||||
using Hutopy.Application;
|
||||
using Hutopy.Infrastructure;
|
||||
using Hutopy.Infrastructure.Data;
|
||||
using Hutopy.Web;
|
||||
using Azure.Identity;
|
||||
using Hutopy.Web.Messages.Data;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NSwag;
|
||||
using NSwag.Generation.AspNetCore.Processors;
|
||||
using NSwag.Generation.Processors.Security;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -16,31 +20,31 @@ if (!builder.Environment.IsDevelopment())
|
||||
}
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", builder =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", builder =>
|
||||
{
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
|
||||
options.AddPolicy("AllowHutopyUi", builder =>
|
||||
{
|
||||
builder.WithOrigins("https://zealous-bay-08204590f.5.azurestaticapps.net")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
|
||||
options.AddPolicy("AllowHutopyUiPreview", builder =>
|
||||
{
|
||||
builder.WithOrigins("https://zealous-bay-08204590f-preview.eastus2.5.azurestaticapps.net")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
|
||||
options.AddPolicy("AllowHutopyUi", builder =>
|
||||
{
|
||||
builder.WithOrigins("https://zealous-bay-08204590f.5.azurestaticapps.net")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
|
||||
options.AddPolicy("AllowHutopyUiPreview", builder =>
|
||||
{
|
||||
builder.WithOrigins("https://zealous-bay-08204590f-preview.eastus2.5.azurestaticapps.net")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddKeyVaultIfConfigured(builder.Configuration);
|
||||
|
||||
@@ -48,6 +52,8 @@ builder.Services.AddApplicationServices();
|
||||
builder.Services.AddInfrastructureServices(builder.Configuration);
|
||||
builder.Services.AddWebServices();
|
||||
builder.Services.AddAuthorizationAndAuthentication(builder.Configuration);
|
||||
|
||||
// TODO: This old tech should be remove - need to move Facebook / Google controllers to FastEndpoints
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddOpenApiDocument((configure, sp) =>
|
||||
@@ -63,11 +69,19 @@ builder.Services.AddOpenApiDocument((configure, sp) =>
|
||||
Type = OpenApiSecuritySchemeType.ApiKey,
|
||||
Name = "Authorization",
|
||||
In = OpenApiSecurityApiKeyLocation.Header,
|
||||
Description = "Type into the textbox: Bearer {your JWT token}."
|
||||
Description = "Type into the textbox: Bearer {your JWT token}.",
|
||||
});
|
||||
|
||||
|
||||
configure.OperationProcessors.Add(new AspNetCoreOperationTagsProcessor());
|
||||
configure.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddFastEndpoints();
|
||||
|
||||
builder.Services.AddDbContext<MessagingDbContext>((_, options) =>
|
||||
{
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("CommentStore"));
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
@@ -110,6 +124,13 @@ app.MapControllerRoute(
|
||||
// app.UseExceptionHandler();
|
||||
app.MapEndpoints();
|
||||
|
||||
app.UseFastEndpoints();
|
||||
|
||||
app.Run();
|
||||
|
||||
public abstract partial class Program { }
|
||||
namespace Hutopy.Web
|
||||
{
|
||||
public abstract partial class Program
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user