Prompt file imported from shakesoft/timekeeper (
.windsurf/workflows/generate-service-proxies.md). Copyright stays with the author.
Generate Service Proxies
Use this command to generate/update Angular and/or React service proxies after adding new backend code.
Usage
Invoke with: /generate-service-proxies [angular|react|both]
When new code is added to the backend and there are no build errors, you need to generate service proxies to keep the frontend clients (Angular and/or React) in sync with the backend API.
Arguments: angular, react, or omit to generate both
Prerequisites
- Ensure the backend has no build errors
- The Host project must be running to generate service proxies
Steps
-
Start the Host project:
PowerShell (Windows):
$workspaceRoot = if (Test-Path "aspnet-core") { Get-Location } else { Get-Location | Split-Path -Parent } cd "$workspaceRoot\aspnet-core\src\CadentManagement.Web.Host" dotnet runGit Bash / WSL / Linux / Mac:
# Automatically finds workspace root (where aspnet-core folder exists) WORKSPACE_ROOT=$(if [ -d "aspnet-core" ]; then pwd; else cd .. && pwd; fi) cd "$WORKSPACE_ROOT/aspnet-core/src/CadentManagement.Web.Host" dotnet run -
Generate service proxies:
For Angular:
PowerShell (Windows):
$workspaceRoot = if (Test-Path "aspnet-core") { Get-Location } else { Get-Location | Split-Path -Parent } cd "$workspaceRoot\angular" npm run nswagOr if using yarn (PowerShell):
$workspaceRoot = if (Test-Path "aspnet-core") { Get-Location } else { Get-Location | Split-Path -Parent } cd "$workspaceRoot\angular" yarn nswagGit Bash / WSL / Linux / Mac:
WORKSPACE_ROOT=$(if [ -d "aspnet-core" ]; then pwd; else cd .. && pwd; fi) cd "$WORKSPACE_ROOT/angular" npm run nswagOr if using yarn (Bash):
WORKSPACE_ROOT=$(if [ -d "aspnet-core" ]; then pwd; else cd .. && pwd; fi) cd "$WORKSPACE_ROOT/angular" yarn nswagFor React:
PowerShell (Windows):
$workspaceRoot = if (Test-Path "aspnet-core") { Get-Location } else { Get-Location | Split-Path -Parent } cd "$workspaceRoot\react\nswag" .\refresh.batGit Bash / WSL / Linux / Mac:
WORKSPACE_ROOT=$(if [ -d "aspnet-core" ]; then pwd; else cd .. && pwd; fi) cd "$WORKSPACE_ROOT/react/nswag" sh refresh.sh -
Stop the Host project:
- You can stop the Host project after generating the service proxies
Description
This command updates the service proxy files:
- Angular:
angular/src/shared/service-proxies/service-proxies.ts - React:
react/src/api/generated/service-proxies.ts
The service proxies are automatically generated by NSwag from the backend Swagger/OpenAPI specification when the Host is running.
Notes
- Always ensure the backend builds successfully before generating service proxies
- The Host project must be running for NSwag to access the Swagger endpoint
- After generating proxies, you can stop the Host project if it's not needed
- Angular: The
npm run nswagscript runscd nswag/ && refresh.bat - React: Run
refresh.bat(Windows) orrefresh.sh(Linux/Mac) directly fromreact/nswag/directory - Generated proxy files are auto-generated — NEVER manually edit them
- Regenerate proxies whenever backend API contracts change (new DTOs, app services, or method signatures)