Imports the previously untracked working tree as-is so that the review changes that follow (requirements -> design -> implementation) can be reviewed as diffs and reverted if needed. No content changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
1.4 KiB
TypeScript
24 lines
1.4 KiB
TypeScript
import {Body,Controller,Inject,Param,Post,Req} from '@nestjs/common';
|
|
import type {Request} from 'express';
|
|
import type {Actor} from '@wishforge/contracts';
|
|
import {z} from 'zod';
|
|
import {Services} from './http.js';
|
|
import {Previews} from './domain/previews.js';
|
|
type AuthRequest=Request&{actor:Actor};
|
|
@Controller('v1/environments')
|
|
export class PreviewController{
|
|
constructor(@Inject(Services)private s:Services){}
|
|
@Post(':id/preview-launch')async launch(@Req()req:AuthRequest,@Param('id')id:string){return{data:await new Previews(this.s.control.store,this.s.control.env).launch(req.actor,id)};}
|
|
}
|
|
/** This path has its own environment-scoped service authentication, not OIDC or worker auth. */
|
|
@Controller('preview-control')
|
|
export class PreviewControlController{
|
|
constructor(@Inject(Services)private s:Services){}
|
|
@Post('authorize')async authorize(@Req()req:Request,@Body()body:unknown){return{data:await new Previews(this.s.control.store,this.s.control.env).authorize(req.header('Authorization'),body)};}
|
|
}
|
|
@Controller('internal/runner/releases')
|
|
export class PreviewProbeController{
|
|
constructor(@Inject(Services)private s:Services){}
|
|
@Post(':id/preview-probe')async probe(@Req()req:AuthRequest,@Param('id')id:string,@Body()body:unknown){const input=z.object({taskId:z.string().regex(/^[A-Za-z0-9_-]{1,128}$/)}).strict().parse(body);return{data:await new Previews(this.s.control.store,this.s.control.env).issueProbeForRunner(req.actor,id,input.taskId)};}
|
|
}
|