Skip to content

Commit 09db96b

Browse files
Use minimal set of APIs in hub service
1 parent 3a4224a commit 09db96b

File tree

1 file changed

+19
-17
lines changed
  • src/Certify.Server/Certify.Server.HubService

1 file changed

+19
-17
lines changed

src/Certify.Server/Certify.Server.HubService/Program.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@
1919
using Microsoft.OpenApi.Models;
2020
using Scalar.AspNetCore;
2121
using Serilog;
22-
using Swashbuckle.AspNetCore.SwaggerGen;
2322

2423
List<ActionStep> _systemStatusItems = [];
2524
void AddSystemStatusItem(string systemStatusCategory, string systemStatusKey, string title, string description, bool hasError = false, bool hasWarning = false) => _systemStatusItems.Add(new ActionStep(systemStatusKey, systemStatusCategory, title, description, hasError, hasWarning));
2625

27-
var assembly = typeof(Certify.Server.Hub.Api.Startup).Assembly;
26+
var hubServiceAssembly = typeof(Certify.Server.HubService.Services.CertifyDirectHubService).Assembly;
2827

2928
// set working directory so that when we are started as a service we can find our config
30-
var cwd = Path.GetDirectoryName(assembly.Location);
29+
var cwd = Path.GetDirectoryName(hubServiceAssembly.Location);
3130
if (cwd != null)
3231
{
33-
3432
System.Diagnostics.Debug.WriteLine($"Using working directory {cwd}");
3533
Directory.SetCurrentDirectory(cwd);
3634
}
@@ -94,10 +92,6 @@
9492
description: "Hub API using directly integrated primary service."
9593
);
9694

97-
// Add services to the container
98-
99-
var part = new AssemblyPart(assembly);
100-
10195
builder.Services.AddCors(options =>
10296
{
10397
options.AddDefaultPolicy(builder =>
@@ -112,7 +106,15 @@
112106
.AddTokenAuthentication(builder.Configuration)
113107
.AddAuthorization()
114108
.AddControllers()
115-
.ConfigureApplicationPartManager(apm => apm.ApplicationParts.Add(part));
109+
.ConfigureApplicationPartManager((apm) =>
110+
{
111+
// remove service core assembly part, as controllers from this assembly are not needed in the hub API
112+
var serviceCore = (apm.ApplicationParts.FirstOrDefault(p => p.Name == "Certify.Server.Core") as AssemblyPart);
113+
if (serviceCore != null)
114+
{
115+
apm.ApplicationParts.Remove(serviceCore);
116+
}
117+
});
116118

117119
builder.Services
118120
.AddRouting(r => r.LowercaseUrls = true)
@@ -153,15 +155,15 @@
153155

154156
c.UseAllOfToExtendReferenceSchemas();
155157

156-
c.DocInclusionPredicate((docName, apiDesc) =>
157-
{
158-
if (!apiDesc.TryGetMethodInfo(out MethodInfo methodInfo))
159-
{
160-
return false;
161-
}
158+
/* c.DocInclusionPredicate((docName, apiDesc) =>
159+
{
160+
if (!apiDesc.TryGetMethodInfo(out MethodInfo methodInfo))
161+
{
162+
return false;
163+
}
162164
163-
return methodInfo.DeclaringType.Namespace.StartsWith("Certify.Server.Hub.Api.Controllers");
164-
});
165+
return methodInfo.DeclaringType.Namespace.StartsWith("Certify.Server.Hub.Api.Controllers");
166+
});*/
165167

166168
// use the actual method names as the generated operation id
167169
c.CustomOperationIds(e =>

0 commit comments

Comments
 (0)