- 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
30 lines
848 B
TypeScript
30 lines
848 B
TypeScript
import type { SeriesResponse } from '../../shared/types'
|
|
import { apiRequest, enumParam, isMockMode, sensorParam } from '../utils/api'
|
|
import { getMockSeries } from '../utils/mock-data'
|
|
|
|
const STEPS = ['15m', '1h'] as const
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const query = getQuery(event)
|
|
const sensor = sensorParam(query.sensor)
|
|
|
|
if (isMockMode()) {
|
|
const series = getMockSeries(sensor)
|
|
if (!series) {
|
|
throw createError({ statusCode: 404, statusMessage: `Unknown sensor: ${sensor}` })
|
|
}
|
|
const step = query.step === '15m' ? '15m' : '1h'
|
|
return { ...series, step }
|
|
}
|
|
|
|
const step = query.step ? enumParam(query.step, STEPS, 'step') : undefined
|
|
return apiRequest<SeriesResponse>('/api/series', {
|
|
query: {
|
|
sensor,
|
|
step,
|
|
from: query.from,
|
|
to: query.to,
|
|
},
|
|
})
|
|
})
|