Configure API to serve SPA, integrate SignalR, and update build paths
This commit is contained in:
+2
-2
@@ -35,8 +35,8 @@ bld/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
# Frontend build output
|
||||
wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
Generated
+15
-6
@@ -9,9 +9,9 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="55603b38-3b47-4a5f-808e-ac484b0d090b" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/API/Controllers/GameController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.4Gewinnt/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.4Gewinnt/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/API/API.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/API/API.csproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/API/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/API/Program.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GUI/vite.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/GUI/vite.config.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -126,7 +126,7 @@
|
||||
<workItem from="1771607712379" duration="87000" />
|
||||
<workItem from="1771607816150" duration="554000" />
|
||||
<workItem from="1771608705474" duration="719000" />
|
||||
<workItem from="1771782531789" duration="1457000" />
|
||||
<workItem from="1771782531789" duration="1886000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Add StatusController, improve local game logic, and enable Swagger in API">
|
||||
<option name="closed" value="true" />
|
||||
@@ -136,7 +136,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1771783305542</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<task id="LOCAL-00002" summary="Add GameController with SignalR functionality for joining games">
|
||||
<option name="closed" value="true" />
|
||||
<created>1771784241189</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1771784241189</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="3" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -158,7 +166,8 @@
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||
<MESSAGE value="Add StatusController, improve local game logic, and enable Swagger in API" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Add StatusController, improve local game logic, and enable Swagger in API" />
|
||||
<MESSAGE value="Add GameController with SignalR functionality for joining games" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Add GameController with SignalR functionality for joining games" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
||||
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
namespace API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class StatusController : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Serve frontend from wwwroot at solution root
|
||||
var webRootPath = Path.GetFullPath(Path.Combine(builder.Environment.ContentRootPath, "..", "wwwroot"));
|
||||
Directory.CreateDirectory(webRootPath);
|
||||
builder.Environment.WebRootPath = webRootPath;
|
||||
builder.WebHost.UseWebRoot(webRootPath);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddSignalR();
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
@@ -18,8 +25,14 @@ if (app.Environment.IsDevelopment())
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
app.MapHub<API.Controllers.GameController>("/api/game");
|
||||
|
||||
// SPA fallback: serve index.html for routes not matched by API or static files
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.Run();
|
||||
|
||||
@@ -15,4 +15,8 @@ export default defineConfig({
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: '../wwwroot',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user