mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
docs: packages,stream,route (3 files)
This commit is contained in:
39
frontends/nextjs/src/app/api/codegen/studio/route.ts
Normal file
39
frontends/nextjs/src/app/api/codegen/studio/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
import { generateCodegenZip } from '@/lib/codegen/generate-codegen-zip'
|
||||
import type { CodegenSpec } from '@/lib/codegen/codegen-types'
|
||||
|
||||
const normalizeRuntime = (value: string | undefined): CodegenSpec['runtime'] => {
|
||||
const runtime = (value ?? 'web').toLowerCase()
|
||||
if (['cli', 'desktop', 'hybrid', 'server'].includes(runtime)) return runtime as CodegenSpec['runtime']
|
||||
return 'web'
|
||||
}
|
||||
|
||||
export const POST = async (req: Request) => {
|
||||
try {
|
||||
const body = (await req.json()) as Partial<CodegenSpec>
|
||||
const spec: CodegenSpec = {
|
||||
projectName: body.projectName?.trim() || 'meta-starter',
|
||||
packageId: body.packageId?.trim() || 'codegen_studio',
|
||||
runtime: normalizeRuntime(body.runtime),
|
||||
tone: body.tone,
|
||||
brief: body.brief,
|
||||
}
|
||||
const { zipBuffer, fileName, manifest } = await generateCodegenZip(spec)
|
||||
const headers = new Headers({
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Disposition': `attachment; filename="${fileName}"`,
|
||||
'X-Codegen-Manifest': encodeURIComponent(JSON.stringify(manifest)),
|
||||
})
|
||||
return new NextResponse(zipBuffer, { status: 200, headers })
|
||||
} catch (error) {
|
||||
console.error('Codegen export failed:', error)
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Unable to generate code bundle',
|
||||
details: error instanceof Error ? error.message : 'unknown error',
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ packages/
|
||||
- **codegen_studio**: Code generation studio with template-driven exports
|
||||
- **forum_forge**: Modern forum starter with categories, threads, and moderation
|
||||
- **arcade_lobby**: Gaming lobby with queues, tournaments, and party setup
|
||||
- **stream_cast**: Live streaming control room with schedules and scene control
|
||||
|
||||
## Package Metadata Format
|
||||
|
||||
|
||||
20
packages/stream_cast/tests/components.test.ts
Normal file
20
packages/stream_cast/tests/components.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import components from '../seed/components.json'
|
||||
|
||||
describe('Stream Cast Components', () => {
|
||||
it('should be a valid array', () => {
|
||||
expect(components).toBeInstanceOf(Array)
|
||||
})
|
||||
|
||||
it('should have valid component structure if components exist', () => {
|
||||
if (components.length > 0) {
|
||||
components.forEach((component: any) => {
|
||||
expect(component.id).toBeDefined()
|
||||
expect(component.type).toBeDefined()
|
||||
expect(typeof component.id).toBe('string')
|
||||
expect(typeof component.type).toBe('string')
|
||||
expect(component.children).toBeInstanceOf(Array)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user