- Replace mock Nitro routes with server-side proxies to the Go API - /plan reads Go /api/staffing; local assumption edits are a labeled preview - /simulate reads base and scenario staffing from Go instead of local multipliers - Route train upload and scenario POST through Nitro with server-only credentials - Keep NUXT_PUBLIC_USE_MOCK=1 as an explicit dev fallback only - Match Go's global-peak flat schedule and add a captured Go parity fixture - Run the web runtime as numeric UID/GID 10001:10001 - Add make check, Gitea CI workflow and a proxy smoke script
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { SCENARIOS } from '../../shared/types'
|
|
import type { Scenario, ScenarioDefinition, ScenarioState } from '../../shared/types'
|
|
import { apiRequest, isMockMode } from '../utils/api'
|
|
import { mockScenario } from '../utils/mock-data'
|
|
|
|
let version = mockScenario.version
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readBody<ScenarioDefinition>(event)
|
|
const scenario = body?.scenario
|
|
if (!scenario || !SCENARIOS.includes(scenario as Scenario)) {
|
|
throw createError({
|
|
statusCode: 400,
|
|
statusMessage: 'Invalid scenario. Expected base | sunny-saturday-market | rainy-saturday | weekday-event.',
|
|
})
|
|
}
|
|
|
|
if (isMockMode()) {
|
|
version += 1
|
|
return {
|
|
version,
|
|
scenario: body,
|
|
at: new Date().toISOString(),
|
|
}
|
|
}
|
|
|
|
// Control credentials are attached in the server process, never in the
|
|
// browser. Go returns 503 until CONTROL_USER/CONTROL_PASS are configured.
|
|
return apiRequest<ScenarioState>('/api/scenario', {
|
|
method: 'POST',
|
|
body,
|
|
control: true,
|
|
})
|
|
})
|