Migrar backend a PostgreSQL + Node.js/Express con nuevas funcionalidades
Backend (water-api/): - Crear API REST completa con Express + TypeScript - Implementar autenticación JWT con refresh tokens - CRUD completo para: projects, concentrators, meters, gateways, devices, users, roles - Agregar validación con Zod para todas las entidades - Implementar webhooks para The Things Stack (LoRaWAN) - Agregar endpoint de lecturas con filtros y resumen de consumo - Implementar carga masiva de medidores via Excel (.xlsx) Frontend: - Crear cliente HTTP con manejo automático de JWT y refresh - Actualizar todas las APIs para usar nuevo backend - Agregar sistema de autenticación real (login, logout, me) - Agregar selector de tipo (LORA, LoRaWAN, Grandes) en concentradores y medidores - Agregar campo Meter ID en medidores - Crear modal de carga masiva para medidores - Agregar página de consumo con gráficas y filtros - Corregir carga de proyectos independiente de datos existentes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
59
water-api/src/routes/concentrator.routes.ts
Normal file
59
water-api/src/routes/concentrator.routes.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Router } from 'express';
|
||||
import { authenticateToken } from '../middleware/auth.middleware';
|
||||
import {
|
||||
validateCreateConcentrator,
|
||||
validateUpdateConcentrator,
|
||||
} from '../validators/concentrator.validator';
|
||||
import * as concentratorController from '../controllers/concentrator.controller';
|
||||
|
||||
const router = Router();
|
||||
|
||||
/**
|
||||
* GET /concentrators
|
||||
* Get all concentrators with optional filters and pagination
|
||||
* Query params: project_id, status, page, limit, sortBy, sortOrder
|
||||
* Protected endpoint - requires authentication
|
||||
*/
|
||||
router.get('/', authenticateToken, concentratorController.getAll);
|
||||
|
||||
/**
|
||||
* GET /concentrators/:id
|
||||
* Get a single concentrator by ID with gateway count
|
||||
* Protected endpoint - requires authentication
|
||||
*/
|
||||
router.get('/:id', authenticateToken, concentratorController.getById);
|
||||
|
||||
/**
|
||||
* POST /concentrators
|
||||
* Create a new concentrator
|
||||
* Body: { serial_number, name?, project_id, location?, status?, ip_address?, firmware_version? }
|
||||
* Protected endpoint - requires authentication
|
||||
*/
|
||||
router.post(
|
||||
'/',
|
||||
authenticateToken,
|
||||
validateCreateConcentrator,
|
||||
concentratorController.create
|
||||
);
|
||||
|
||||
/**
|
||||
* PUT /concentrators/:id
|
||||
* Update an existing concentrator
|
||||
* Body: { serial_number?, name?, project_id?, location?, status?, ip_address?, firmware_version? }
|
||||
* Protected endpoint - requires authentication
|
||||
*/
|
||||
router.put(
|
||||
'/:id',
|
||||
authenticateToken,
|
||||
validateUpdateConcentrator,
|
||||
concentratorController.update
|
||||
);
|
||||
|
||||
/**
|
||||
* DELETE /concentrators/:id
|
||||
* Delete a concentrator (fails if gateways are associated)
|
||||
* Protected endpoint - requires authentication
|
||||
*/
|
||||
router.delete('/:id', authenticateToken, concentratorController.remove);
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user