feat: Add pedigree routes for COI calculation, direct relation checks, and ancestral/descendant trees.
This commit is contained in:
@@ -124,8 +124,7 @@ function calculateCOI(db, sireId, damId) {
|
|||||||
// 'trial-pairing' as dog IDs and return 404/wrong data.
|
// 'trial-pairing' as dog IDs and return 404/wrong data.
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
// POST /api/pedigree/trial-pairing (alias for /coi)
|
const handleTrialPairing = (req, res) => {
|
||||||
router.post(['/trial-pairing', '/coi'], (req, res) => {
|
|
||||||
try {
|
try {
|
||||||
const { sire_id, dam_id } = req.body;
|
const { sire_id, dam_id } = req.body;
|
||||||
if (!sire_id || !dam_id) {
|
if (!sire_id || !dam_id) {
|
||||||
@@ -156,7 +155,13 @@ router.post(['/trial-pairing', '/coi'], (req, res) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// POST /api/pedigree/trial-pairing
|
||||||
|
router.post('/trial-pairing', handleTrialPairing);
|
||||||
|
|
||||||
|
// POST /api/pedigree/coi
|
||||||
|
router.post('/coi', handleTrialPairing);
|
||||||
|
|
||||||
// GET /api/pedigree/:id/coi
|
// GET /api/pedigree/:id/coi
|
||||||
router.get('/:id/coi', (req, res) => {
|
router.get('/:id/coi', (req, res) => {
|
||||||
|
|||||||
26
server/test_app.js
Normal file
26
server/test_app.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const app = require('./index');
|
||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
// Start temporary server
|
||||||
|
const server = http.createServer(app);
|
||||||
|
server.listen(3030, async () => {
|
||||||
|
console.log('Server started on 3030');
|
||||||
|
try {
|
||||||
|
const res = await fetch('http://localhost:3030/api/pedigree/relations/1/2');
|
||||||
|
const text = await res.text();
|
||||||
|
console.log('GET /api/pedigree/relations/1/2 RESPONSE:', res.status, text.substring(0, 150));
|
||||||
|
|
||||||
|
const postRes = await fetch('http://localhost:3030/api/pedigree/trial-pairing', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ sire_id: 1, dam_id: 2 })
|
||||||
|
});
|
||||||
|
const postText = await postRes.text();
|
||||||
|
console.log('POST /api/pedigree/trial-pairing RESPONSE:', postRes.status, postText.substring(0, 150));
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Fetch error:', err);
|
||||||
|
} finally {
|
||||||
|
server.close();
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
8
server/test_express.js
Normal file
8
server/test_express.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.post(['/a', '/b'], (req, res) => {
|
||||||
|
res.send('ok');
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Started successfully');
|
||||||
Reference in New Issue
Block a user