import { Controller, Get, UseGuards } from "@nestjs/common"; import { WorkspacesService } from "./workspaces.service"; import { AuthGuard } from "../auth/guards/auth.guard"; import { CurrentUser } from "../auth/decorators/current-user.decorator"; import type { AuthUser } from "@mosaic/shared"; import type { WorkspaceResponseDto } from "./dto"; /** * User-scoped workspace operations. * * Intentionally does NOT use WorkspaceGuard — these routes operate across all * workspaces the user belongs to, not within a single workspace context. */ @Controller("workspaces") @UseGuards(AuthGuard) export class WorkspacesController { constructor(private readonly workspacesService: WorkspacesService) {} /** * GET /api/workspaces * Returns workspaces the authenticated user is a member of. * Auto-provisions a default workspace if the user has none. */ @Get() async getUserWorkspaces(@CurrentUser() user: AuthUser): Promise { return this.workspacesService.getUserWorkspaces(user.id); } }