diff --git a/backend/ResQueue/ResQueue.sln.DotSettings b/backend/ResQueue/ResQueue.sln.DotSettings index 640d2ea..04db52e 100644 --- a/backend/ResQueue/ResQueue.sln.DotSettings +++ b/backend/ResQueue/ResQueue.sln.DotSettings @@ -1,3 +1,5 @@  True - True \ No newline at end of file + True + True + True \ No newline at end of file diff --git a/backend/ResQueue/ResQueue/Features/Messages/RequeueMessages/RequeueMessagesFeature.cs b/backend/ResQueue/ResQueue/Features/Messages/RequeueMessages/RequeueMessagesFeature.cs index 3581509..6868c0d 100644 --- a/backend/ResQueue/ResQueue/Features/Messages/RequeueMessages/RequeueMessagesFeature.cs +++ b/backend/ResQueue/ResQueue/Features/Messages/RequeueMessages/RequeueMessagesFeature.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Npgsql; -using ResQueue.Dtos; using ResQueue.Dtos.Messages; namespace ResQueue.Features.Messages.RequeueMessages; diff --git a/backend/ResQueue/ResQueue/ResQueue.csproj b/backend/ResQueue/ResQueue/ResQueue.csproj index 07a9ffb..2823356 100644 --- a/backend/ResQueue/ResQueue/ResQueue.csproj +++ b/backend/ResQueue/ResQueue/ResQueue.csproj @@ -9,10 +9,11 @@ true Library + true ResQueue.MassTransit - 1.0.0-beta.3 + 1.0.0-beta.5 Filip Bekić ResQueue MassTransit SQL Transport Web UI @@ -28,33 +29,12 @@ true snupkg $(OutputPath) - - - true - - - - - - - - - - - - - - - + - - - - diff --git a/backend/ResQueue/ResQueue/ResQueueExtensions.cs b/backend/ResQueue/ResQueue/ResQueueExtensions.cs index ed68d8a..b5eff8e 100644 --- a/backend/ResQueue/ResQueue/ResQueueExtensions.cs +++ b/backend/ResQueue/ResQueue/ResQueueExtensions.cs @@ -1,5 +1,6 @@ +using System.Reflection; using Microsoft.AspNetCore.Rewrite; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.FileProviders; using ResQueue.Endpoints; using ResQueue.Features.Messages.RequeueMessages; using ResQueue.Features.Messages.RequeueSpecificMessages; @@ -11,25 +12,25 @@ public static class ResQueueExtensions public static WebApplicationBuilder AddResQueue(this WebApplicationBuilder builder, Action configureOptions) { - // Configure IOptions builder.Services.Configure(configureOptions); - // Configure CORS - builder.Services.AddCors(corsOptions => + if (builder.Environment.IsDevelopment()) { - corsOptions.AddPolicy("AllowAll", policy => + builder.Services.AddCors(corsOptions => { - policy.SetIsOriginAllowed(_ => true); - policy.AllowAnyHeader(); - policy.AllowAnyMethod(); - policy.AllowCredentials(); + corsOptions.AddPolicy("AllowAll", policy => + { + policy.SetIsOriginAllowed(_ => true); + policy.AllowAnyHeader(); + policy.AllowAnyMethod(); + policy.AllowCredentials(); + }); }); - }); + } - // Add HTTP Client + // todo: Remove if not used anymore. builder.Services.AddHttpClient(); - // Register features builder.Services.AddTransient(); builder.Services.AddTransient(); @@ -38,16 +39,6 @@ public static WebApplicationBuilder AddResQueue(this WebApplicationBuilder build public static IApplicationBuilder UseResQueue(this WebApplication app) { - // Use CORS policy - app.UseCors("AllowAll"); - - // Temporary internal server error fix - if (!app.Environment.IsDevelopment()) - { - app.UseExceptionHandler(configure => configure.Run(_ => Task.CompletedTask)); - } - - // Configure frontend route rewriting string[] frontendRoutes = { "^resqueue-ui", @@ -57,21 +48,37 @@ public static IApplicationBuilder UseResQueue(this WebApplication app) new RewriteOptions(), (options, route) => options.AddRewrite(route, "/index.html", true)) ); - - // Serve static files - app.UseDefaultFiles(); - app.UseStaticFiles(new StaticFileOptions() + + if (app.Environment.IsDevelopment()) { - OnPrepareResponse = (context) => + app.UseCors("AllowAll"); + + app.UseDefaultFiles(); + app.UseStaticFiles(); + } + else + { + var assembly = typeof(ResQueueExtensions).GetTypeInfo().Assembly; + var embeddedProvider = new EmbeddedFileProvider(assembly, "ResQueue.staticwebassets"); + + app.UseDefaultFiles(new DefaultFilesOptions() + { + FileProvider = embeddedProvider + }); + + app.UseStaticFiles(new StaticFileOptions() { - context.Context.Response.Headers.CacheControl = - context.Context.Request.Path.StartsWithSegments("/assets") - ? "public, max-age=31536000, immutable" - : "no-cache, no-store"; - } - }); + FileProvider = embeddedProvider, + OnPrepareResponse = (context) => + { + context.Context.Response.Headers.CacheControl = + context.Context.Request.Path.StartsWithSegments("/assets") + ? "public, max-age=31536000, immutable" + : "no-cache, no-store"; + } + }); + } - // Map API endpoints var apiGroup = app.MapGroup("resqueue-api"); apiGroup.MapQueueEndpoints(); apiGroup.MapMessageEndpoints(); diff --git a/backend/ResQueue/WebSample/Properties/launchSettings.json b/backend/ResQueue/WebSample/Properties/launchSettings.json index 385649f..93adb0b 100644 --- a/backend/ResQueue/WebSample/Properties/launchSettings.json +++ b/backend/ResQueue/WebSample/Properties/launchSettings.json @@ -12,7 +12,7 @@ "http": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": true, + "launchBrowser": false, "applicationUrl": "http://localhost:5146", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/backend/ResQueue/WebSample/WebSample.csproj b/backend/ResQueue/WebSample/WebSample.csproj index 997f9cb..476fa91 100644 --- a/backend/ResQueue/WebSample/WebSample.csproj +++ b/backend/ResQueue/WebSample/WebSample.csproj @@ -14,7 +14,10 @@ - - + + + + + diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index ef81202..00c0514 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -10,29 +10,31 @@ const router = createRouter({ routes: [ { path: '/resqueue-ui', - redirect: '/overview', + redirect: { + name: 'overview' + }, component: Broker, children: [ { - path: '/overview', + path: '/resqueue-ui/overview', name: 'overview', props: true, component: BrokerOverview }, { - path: '/topics', + path: '/resqueue-ui/topics', name: 'topics', props: true, component: BrokerTopics }, { - path: '/queues', + path: '/resqueue-ui/queues', name: 'queues', props: true, component: BrokerQueues }, { - path: '/jobs', + path: '/resqueue-ui/jobs', name: 'jobs', props: true, component: BrokerQueues