Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
filipbekic01 committed Oct 23, 2024
1 parent ce87329 commit c422289
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 67 deletions.
4 changes: 3 additions & 1 deletion backend/ResQueue/ResQueue.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=dtos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=postgre/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=postgre/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=resqueue/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=staticwebassets/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 3 additions & 23 deletions backend/ResQueue/ResQueue/ResQueue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
<PropertyGroup>
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>

<!-- NuGet package properties -->
<PackageId>ResQueue.MassTransit</PackageId>
<Version>1.0.0-beta.3</Version>
<Version>1.0.0-beta.5</Version>
<Authors>Filip Bekić</Authors>
<Company>ResQueue</Company>
<Description>MassTransit SQL Transport Web UI</Description>
Expand All @@ -28,33 +29,12 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageOutputPath>$(OutputPath)</PackageOutputPath>

<!-- Required for NuGet package -->
<IsPackable>true</IsPackable>
</PropertyGroup>

<!-- <Target Name="Deploy Vue" BeforeTargets="Publish">-->
<!-- <Exec Command="npm ci" WorkingDirectory="../../../frontend"/>-->
<!-- <Exec Command="npm run build:prod" WorkingDirectory="../../../frontend"/>-->
<!-- <RemoveDir Directories="$(PublishDir)wwwroot"/>-->
<!-- <ItemGroup>-->
<!-- <CopyDist Include="../../../frontend/dist/**/*.*"/>-->
<!-- </ItemGroup>-->
<!-- <Copy SourceFiles="@(CopyDist)" DestinationFiles="@(CopyDist->'$(PublishDir)wwwroot\%(RecursiveDir)%(Filename)%(Extension)')"/>-->
<!-- </Target>-->

<ItemGroup>
<Compile Remove="Features\Stripe\UpdateSeats\**\*.cs"/>
</ItemGroup>


<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35"/>
<PackageReference Include="Npgsql" Version="8.0.5"/>
<PackageReference Include="Marten" Version="7.30.1"/>
<PackageReference Include="NewId" Version="4.0.1"/>
</ItemGroup>

<ItemGroup>
<None Remove="Properties\launchSettings.json"/>
</ItemGroup>
</Project>
75 changes: 41 additions & 34 deletions backend/ResQueue/ResQueue/ResQueueExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,25 +12,25 @@ public static class ResQueueExtensions
public static WebApplicationBuilder AddResQueue(this WebApplicationBuilder builder,
Action<Settings> configureOptions)
{
// Configure IOptions<ResQueueOptions>
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<IRequeueMessagesFeature, RequeueMessagesFeature>();
builder.Services.AddTransient<IRequeueSpecificMessagesFeature, RequeueSpecificMessagesFeature>();

Expand All @@ -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",
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion backend/ResQueue/WebSample/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5146",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
7 changes: 5 additions & 2 deletions backend/ResQueue/WebSample/WebSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
<PackageReference Include="MassTransit.SqlTransport.SqlServer" Version="8.3.1-develop.2089"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1"/>
<PackageReference Include="ResQueue.MassTransit" Version="1.0.0-beta.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ResQueue\ResQueue.csproj"/>
</ItemGroup>
</Project>
12 changes: 7 additions & 5 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c422289

Please sign in to comment.