import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common'; import type { Request } from 'express'; import { z } from 'zod'; import type { Actor } from '@wishforge/contracts'; import { Services } from './http.js'; import { WorkspaceLaunch } from './domain/workspace-launch.js'; @Controller('v1/workspaces') export class WorkspaceLaunchController { constructor(@Inject(Services) private s: Services) {} @Post(':id/launch') async launch( @Req() req: Request & { actor: Actor }, @Param('id') id: string, @Body() body: unknown, ) { z.object({}).strict().parse(body); return { data: await new WorkspaceLaunch(this.s.control.store, this.s.control.env).launch( req.actor, id, req.header('Authorization') ?? '', ), }; } }