Gauntlet-Incept MCP
by Birdsmith
- src
- api
/**
* Article API Routes
*
* This file defines the routes for the Article API endpoints:
* - tagArticle: Identifies subject, grade, standard, and lesson of a given article
* - gradeArticle: Evaluates a tagged article against quality standards
* - generateArticle: Creates articles based on specified tags or example articles
*/
const express = require('express');
const router = express.Router();
// Import services
const articleService = require('../services/articleService');
/**
* @route POST /api/article/tag
* @desc Tag an article with subject, grade, standard, and lesson
* @access Public
*/
router.post('/tag', async (req, res) => {
try {
const { article } = req.body;
if (!article) {
return res.status(400).json({
success: false,
error: 'Article content is required'
});
}
const tags = await articleService.tagArticle(article);
return res.status(200).json({
success: true,
data: tags
});
} catch (error) {
return res.status(500).json({
success: false,
error: error.message
});
}
});
/**
* @route POST /api/article/grade
* @desc Grade a tagged article against quality standards
* @access Public
*/
router.post('/grade', async (req, res) => {
try {
const { article, tags } = req.body;
if (!article) {
return res.status(400).json({
success: false,
error: 'Article content is required'
});
}
if (!tags) {
return res.status(400).json({
success: false,
error: 'Article tags are required'
});
}
const gradeResult = await articleService.gradeArticle(article, tags);
return res.status(200).json({
success: true,
data: gradeResult
});
} catch (error) {
return res.status(500).json({
success: false,
error: error.message
});
}
});
/**
* @route POST /api/article/generate
* @desc Generate an article based on tags or an example article
* @access Public
*/
router.post('/generate', async (req, res) => {
try {
const { tags, exampleArticle } = req.body;
if (!tags && !exampleArticle) {
return res.status(400).json({
success: false,
error: 'Either tags or an example article is required'
});
}
const generatedArticle = await articleService.generateArticle(tags, exampleArticle);
return res.status(200).json({
success: true,
data: generatedArticle
});
} catch (error) {
return res.status(500).json({
success: false,
error: error.message
});
}
});
module.exports = router;