feat: gateway CRUD routes — conversations, projects, missions, tasks (P1-005/006) (#72)

Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #72.
This commit is contained in:
2026-03-13 02:41:03 +00:00
committed by jason.woltje
parent 38897fe423
commit c54b69f7ce
17 changed files with 417 additions and 3 deletions

View File

@@ -0,0 +1,61 @@
import {
Body,
Controller,
Delete,
Get,
HttpCode,
HttpStatus,
Inject,
NotFoundException,
Param,
Patch,
Post,
UseGuards,
} from '@nestjs/common';
import type { Brain } from '@mosaic/brain';
import { BRAIN } from '../brain/brain.module.js';
import { AuthGuard } from '../auth/auth.guard.js';
import { CurrentUser } from '../auth/current-user.decorator.js';
import type { CreateProjectDto, UpdateProjectDto } from './projects.dto.js';
@Controller('api/projects')
@UseGuards(AuthGuard)
export class ProjectsController {
constructor(@Inject(BRAIN) private readonly brain: Brain) {}
@Get()
async list() {
return this.brain.projects.findAll();
}
@Get(':id')
async findOne(@Param('id') id: string) {
const project = await this.brain.projects.findById(id);
if (!project) throw new NotFoundException('Project not found');
return project;
}
@Post()
async create(@CurrentUser() user: { id: string }, @Body() dto: CreateProjectDto) {
return this.brain.projects.create({
name: dto.name,
description: dto.description,
status: dto.status,
ownerId: user.id,
});
}
@Patch(':id')
async update(@Param('id') id: string, @Body() dto: UpdateProjectDto) {
const project = await this.brain.projects.update(id, dto);
if (!project) throw new NotFoundException('Project not found');
return project;
}
@Delete(':id')
@HttpCode(HttpStatus.NO_CONTENT)
async remove(@Param('id') id: string) {
const deleted = await this.brain.projects.remove(id);
if (!deleted) throw new NotFoundException('Project not found');
}
}