feat: build Onyx SSR shell and plan hero with mock data
This commit is contained in:
1 parent
84c20992f9
commit
2db494fb10
34 files changed
+3197
-2
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { createMockTrainJob } from '../utils/train-jobs'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
let model: 'small' | 'forecast' = 'small'
|
||||
let filename: string | null = null
|
||||
|
||||
const contentType = getRequestHeader(event, 'content-type') ?? ''
|
||||
if (contentType.includes('multipart/form-data')) {
|
||||
const parts = await readMultipartFormData(event)
|
||||
for (const part of parts ?? []) {
|
||||
if (part.name === 'model' && part.data) {
|
||||
const value = part.data.toString()
|
||||
if (value === 'small' || value === 'forecast') model = value
|
||||
}
|
||||
if (part.name === 'file' && part.filename) {
|
||||
filename = part.filename
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const body = await readBody<{ model?: 'small' | 'forecast'; path?: string }>(event).catch(() => null)
|
||||
if (body?.model === 'small' || body?.model === 'forecast') model = body.model
|
||||
if (body?.path) filename = body.path
|
||||
}
|
||||
|
||||
const job = createMockTrainJob(model, filename)
|
||||
setResponseStatus(event, 202)
|
||||
return {
|
||||
job_id: job.job_id,
|
||||
status: job.status,
|
||||
model: job.model,
|
||||
submitted_at: job.started_at,
|
||||
mock: true,
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user