docs: tighten README quick start and stale comments
- Lead with purpose and exact local/CI commands. - Remove local absolute paths, stale auth notes and unverified claims. - Keep comments to the reason or invariant they protect.
This commit is contained in:
1 parent
dbb7a009a7
commit
66b80a62fb
14 files changed
+82
-84
No files matched your search
@@ -1,12 +1,8 @@
|
||||
import { apiBaseUrl, isMockMode } from '../utils/api'
|
||||
|
||||
/**
|
||||
* Same-origin SSE proxy. The browser never talks to Go directly, so the
|
||||
* Cloudflare/K8s CORS surface stays closed and the stream can be cached or
|
||||
* authenticated at one edge only.
|
||||
*
|
||||
* h3's proxyRequest pipes response chunks as they arrive (it does not await
|
||||
* the full body), which preserves the 15 s heartbeat and `retry: 3000`.
|
||||
* Same-origin SSE proxy: the browser talks only to Nitro, so CORS stays closed.
|
||||
* proxyRequest forwards chunks as they arrive, preserving heartbeats and retry hints.
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
if (isMockMode() || process.env.NUXT_DISABLE_SSE === '1') {
|
||||
|
||||
@@ -35,8 +35,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Stream the multipart CSV to Go unchanged. The control credentials are
|
||||
// attached by the Nitro process and never reach the browser bundle.
|
||||
// Forward the raw multipart CSV to Go; control credentials stay in this process.
|
||||
const contentType = getRequestHeader(event, 'content-type') ?? ''
|
||||
if (!contentType) {
|
||||
throw createError({
|
||||
|
||||
@@ -39,10 +39,8 @@ function isProtected(event: import('h3').H3Event): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter-only control surface. Basic auth is checked in Nitro; on success
|
||||
* an HMAC cookie (signed with CONTROL_PASS) lets the page POST /api/scenario
|
||||
* without re-prompting. The browser never receives the Go credentials, and
|
||||
* /stage, /live and all public GETs stay open.
|
||||
* Presenter control: Basic auth at Nitro, then an HMAC cookie (signed with
|
||||
* CONTROL_PASS) lets /control POST without re-prompting. Public GETs stay open.
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
if (!isProtected(event)) return
|
||||
|
||||
+5
-10
@@ -1,6 +1,5 @@
|
||||
// Server-side Go API client. Every Nitro route uses this module so the browser
|
||||
// only ever talks to the Nuxt origin: the Go base URL and the control
|
||||
// credentials stay in the Node process.
|
||||
// Server-side Go API client. Nitro routes use it so the browser only talks to
|
||||
// this origin and control credentials stay in the Node process.
|
||||
|
||||
interface ApiErrorEnvelope {
|
||||
error?: { code?: string; message?: string }
|
||||
@@ -39,7 +38,7 @@ export function apiBaseUrl(): string {
|
||||
).replace(/\/+$/, '')
|
||||
}
|
||||
|
||||
/** True only when NUXT_USE_MOCK=1 / NUXT_PUBLIC_USE_MOCK=1 is set. */
|
||||
/** Mock mode is opt-in via NUXT_USE_MOCK or NUXT_PUBLIC_USE_MOCK (1/true). */
|
||||
export function isMockMode(): boolean {
|
||||
const config = useRuntimeConfig()
|
||||
const raw =
|
||||
@@ -54,8 +53,7 @@ function controlAuthorization(): string | undefined {
|
||||
if (user && pass) return `Basic ${Buffer.from(`${user}:${pass}`).toString('base64')}`
|
||||
|
||||
const token = envValue('CONTROL_TOKEN', 'NUXT_CONTROL_TOKEN') || String(config.controlToken ?? '')
|
||||
// Go currently validates Basic auth; Bearer is accepted here for the future
|
||||
// token-based control surface without exposing the token to the browser.
|
||||
// Go requires Basic today; Bearer is a fallback for a future token-based API.
|
||||
if (token) return `Bearer ${token}`
|
||||
return undefined
|
||||
}
|
||||
@@ -121,10 +119,7 @@ export async function apiRequest<T>(path: string, options: ApiRequestOptions = {
|
||||
return response._data as T
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward a request body (training upload) and preserve Go's status code and
|
||||
* JSON body, including 202/400/409/502 responses that are part of the flow.
|
||||
*/
|
||||
/** Forward a training upload and keep Go's status code for 202/4xx/5xx. */
|
||||
export async function apiForward<T>(
|
||||
event: import('h3').H3Event,
|
||||
path: string,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Server-side mock dataset. Shapes follow /home/noel/Documents/Hackathon_2026/CONTRACT.md.
|
||||
// The files are imported (not read from disk at runtime) so the Nitro build bundles them
|
||||
// into the SSR output and the app renders before the Go API exists.
|
||||
// Server-side mock dataset. Shapes follow the Go API contract; files are imported
|
||||
// so Nitro bundles them and mock mode renders without the Go API.
|
||||
import context from '../../mock/context.json'
|
||||
import demo from '../../mock/demo.json'
|
||||
import meta from '../../mock/meta.json'
|
||||
|
||||
@@ -18,8 +18,7 @@ export function createMockTrainJob(model: 'small' | 'forecast', filename: string
|
||||
const now = new Date().toISOString()
|
||||
const job: MockTrainJob = {
|
||||
job_id: `mock-${Date.now().toString(36)}`,
|
||||
// The mock completes immediately. Replace this with polling of GET /api/train/{job_id}
|
||||
// once the Go/FastAPI service exists.
|
||||
// The mock completes immediately; the real path polls GET /api/train/{job_id}.
|
||||
status: 'succeeded',
|
||||
model,
|
||||
started_at: now,
|
||||
|
||||
Reference in new issue
Block a user