docs: packages,stream,route (3 files)

This commit is contained in:
2025-12-26 01:06:12 +00:00
parent 12737a0d68
commit 0af59837ff
3 changed files with 60 additions and 0 deletions

View 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 }
)
}
}

View File

@@ -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

View 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)
})
}
})
})