Session 28: Parlay builder, line movement tracker, book comparison — 3 features, zero credits (1623 tests)

This commit is contained in:
Kev
2026-06-13 12:37:08 -04:00
parent 66fafd8429
commit c48aecd510
23 changed files with 1567 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
'use strict';
/**
* /api/parlay (Session 28)
*
* Builder-side parlay math — combined odds, grade, and correlation flags
* for a set of user-selected legs. Distinct from the existing parlay
* GRADING path (parlayGrader); this is the lightweight, zero-credit
* combination used by the live parlay builder.
*
* POST /api/parlay/calculate { legs: [...] } → combined analysis
* POST /api/parlay/suggestions { props, legs?, max? } → suggested combos
*/
const express = require('express');
const parlayService = require('../services/parlayService');
const router = express.Router();
const MISSION_HEADER = { 'X-VYNDR-Mission': 'Catch the legs that fight each other' };
router.post('/calculate', (req, res) => {
try {
const legs = req.body?.legs;
const result = parlayService.calculateParlay(legs);
return res.set(MISSION_HEADER).json(result);
} catch (err) {
const status = err.statusCode || 400;
return res.status(status).set(MISSION_HEADER).json({ error: err.message });
}
});
router.post('/suggestions', (req, res) => {
try {
const { props, legs, max } = req.body || {};
const suggestions = parlayService.suggestParlays(props || [], {
legs: Number(legs) || 3,
max: Number(max) || 3,
});
return res.set(MISSION_HEADER).json({ suggestions });
} catch (err) {
return res.status(400).set(MISSION_HEADER).json({ error: err.message });
}
});
module.exports = router;