feat: add domains, ideas, layouts, widgets API modules
- Add DomainsModule with full CRUD, search, and activity logging - Add IdeasModule with quick capture endpoint - Add LayoutsModule for user dashboard layouts - Add WidgetsModule for widget definitions (read-only) - Update ActivityService with domain/idea logging methods - Register all new modules in AppModule
This commit is contained in:
104
apps/api/src/domains/domains.controller.ts
Normal file
104
apps/api/src/domains/domains.controller.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Patch,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
Query,
|
||||
UseGuards,
|
||||
Request,
|
||||
UnauthorizedException,
|
||||
} from "@nestjs/common";
|
||||
import { DomainsService } from "./domains.service";
|
||||
import { CreateDomainDto, UpdateDomainDto, QueryDomainsDto } from "./dto";
|
||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||
|
||||
/**
|
||||
* Controller for domain endpoints
|
||||
* All endpoints require authentication
|
||||
*/
|
||||
@Controller("domains")
|
||||
@UseGuards(AuthGuard)
|
||||
export class DomainsController {
|
||||
constructor(private readonly domainsService: DomainsService) {}
|
||||
|
||||
/**
|
||||
* POST /api/domains
|
||||
* Create a new domain
|
||||
*/
|
||||
@Post()
|
||||
async create(@Body() createDomainDto: CreateDomainDto, @Request() req: any) {
|
||||
const workspaceId = req.user?.workspaceId;
|
||||
const userId = req.user?.id;
|
||||
|
||||
if (!workspaceId || !userId) {
|
||||
throw new UnauthorizedException("Authentication required");
|
||||
}
|
||||
|
||||
return this.domainsService.create(workspaceId, userId, createDomainDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/domains
|
||||
* Get paginated domains with optional filters
|
||||
*/
|
||||
@Get()
|
||||
async findAll(@Query() query: QueryDomainsDto, @Request() req: any) {
|
||||
const workspaceId = req.user?.workspaceId;
|
||||
if (!workspaceId) {
|
||||
throw new UnauthorizedException("Authentication required");
|
||||
}
|
||||
return this.domainsService.findAll({ ...query, workspaceId });
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/domains/:id
|
||||
* Get a single domain by ID
|
||||
*/
|
||||
@Get(":id")
|
||||
async findOne(@Param("id") id: string, @Request() req: any) {
|
||||
const workspaceId = req.user?.workspaceId;
|
||||
if (!workspaceId) {
|
||||
throw new UnauthorizedException("Authentication required");
|
||||
}
|
||||
return this.domainsService.findOne(id, workspaceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* PATCH /api/domains/:id
|
||||
* Update a domain
|
||||
*/
|
||||
@Patch(":id")
|
||||
async update(
|
||||
@Param("id") id: string,
|
||||
@Body() updateDomainDto: UpdateDomainDto,
|
||||
@Request() req: any
|
||||
) {
|
||||
const workspaceId = req.user?.workspaceId;
|
||||
const userId = req.user?.id;
|
||||
|
||||
if (!workspaceId || !userId) {
|
||||
throw new UnauthorizedException("Authentication required");
|
||||
}
|
||||
|
||||
return this.domainsService.update(id, workspaceId, userId, updateDomainDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /api/domains/:id
|
||||
* Delete a domain
|
||||
*/
|
||||
@Delete(":id")
|
||||
async remove(@Param("id") id: string, @Request() req: any) {
|
||||
const workspaceId = req.user?.workspaceId;
|
||||
const userId = req.user?.id;
|
||||
|
||||
if (!workspaceId || !userId) {
|
||||
throw new UnauthorizedException("Authentication required");
|
||||
}
|
||||
|
||||
return this.domainsService.remove(id, workspaceId, userId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user