52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const contextController = require('../controllers/contextController');
|
|
const { authenticateToken } = require('../middleware/auth');
|
|
|
|
/**
|
|
* Context Routes - Workflow-based
|
|
* Status: 0 (Draft) -> 1 (Enriched) -> 2 (Prompt Ready) -> 3 (Generating) -> 4 (Image Ready) -> 5 (Approved)
|
|
*/
|
|
|
|
// Create new context (Title, Desc, Grade) - Status 0
|
|
router.post('/', contextController.createContext);
|
|
|
|
// Get contexts by status
|
|
router.get('/status/:status', contextController.getContextsByStatus);
|
|
|
|
// Status 0 -> 1: Update knowledge
|
|
router.post('/:id/enrich', contextController.enrichContext);
|
|
|
|
// Status 1 -> 2: Update context and img_prompt
|
|
router.post('/:id/prepare-prompt', contextController.preparePrompt);
|
|
|
|
// Status 2 -> 3 or 1: Update status
|
|
router.post('/:id/update-status', contextController.updateStatusFromPromptReady);
|
|
|
|
// Bulk update all status 2 to status 3
|
|
router.post('/bulk/status-2-to-3', contextController.bulkUpdateStatus2To3);
|
|
|
|
// Status 3 -> 4: Add images
|
|
router.post('/:id/add-images', contextController.addImages);
|
|
|
|
// Status 4 -> 5: Approve
|
|
router.post('/:id/approve', contextController.approveContext);
|
|
|
|
// Search contexts: partial match on title/context + filter by type_image, status, etc.
|
|
// Body: { search, title, context_text, type_image, type, status, grade, page, limit }
|
|
router.post('/search', contextController.searchContexts);
|
|
|
|
// Get all contexts (with optional filters)
|
|
router.get('/', contextController.getAllContexts);
|
|
|
|
// Get context by UUID
|
|
router.get('/:id', contextController.getContextById);
|
|
|
|
// Update context (general - use with caution)
|
|
router.put('/:id', contextController.updateContext);
|
|
|
|
// Delete context
|
|
router.delete('/:id', contextController.deleteContext);
|
|
|
|
module.exports = router;
|