feat: Implement element CRUD API endpoints with RBAC
This commit is contained in:
@@ -1,5 +1,31 @@
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import { authenticate, authorizeProjectMember, authorizePlannerPlus } from '../middleware/auth';
|
||||
import { getElements, createElement, updateElement, deleteElement, batchElements } from '../controllers/elementController';
|
||||
import { validateElementCreation, validateElementUpdate, validateBatchElements } from '../validators/elementValidator';
|
||||
|
||||
export default async function elementsRoutes(fastify: FastifyInstance) {
|
||||
// Placeholder for elements routes
|
||||
// GET /projects/:projectId/elements - List elements (filtered by layer, type, bbox query params)
|
||||
fastify.get('/', {
|
||||
preHandler: [authenticate, authorizeProjectMember]
|
||||
}, getElements);
|
||||
|
||||
// POST /projects/:projectId/elements/ - Create element (Planner+)
|
||||
fastify.post('/', {
|
||||
preHandler: [authenticate, authorizeProjectMember, authorizePlannerPlus]
|
||||
}, createElement);
|
||||
|
||||
// PUT /projects/:projectId/elements/:elementId - Update element (Planner+)
|
||||
fastify.put('/:elementId', {
|
||||
preHandler: [authenticate, authorizeProjectMember, authorizePlannerPlus]
|
||||
}, updateElement);
|
||||
|
||||
// DELETE /projects/:projectId/elements/:elementId - Delete element (Planner+)
|
||||
fastify.delete('/:elementId', {
|
||||
preHandler: [authenticate, authorizeProjectMember, authorizePlannerPlus]
|
||||
}, deleteElement);
|
||||
|
||||
// POST /projects/:projectId/elements/batch - Batch operations (create/update/delete multiple, Planner+)
|
||||
fastify.post('/batch', {
|
||||
preHandler: [authenticate, authorizeProjectMember, authorizePlannerPlus]
|
||||
}, batchElements);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user