This repository has been archived on 2024-04-05. You can view files and clone it, but cannot push or open issues/pull-requests.
score-tracker/routes/data.js

31 lines
920 B
JavaScript

var express = require('express');
var router = express.Router();
var sports = require('../database/scores/sports');
var seasons = require('../database/scores/seasons');
var genders = require('../database/scores/genders');
var divisions = require('../database/scores/divisions');
router.get('/sports', function(req, res, next) {
sports.retrieveAll()
.then(data => res.json(data));
});
router.get('/seasons', function(req, res, next) {
seasons.retrieveAll()
.then(data => res.json(data));
})
router.get('/genders', function(req, res, next) {
genders.retrieveBySport(req.query.sport)
.then(data => res.json(data));
})
router.get('/divisions', function(req, res, next) {
const gender = req.body.gender == 'female' ? genders.FEMALE : genders.MALE;
divisions.retrieveBySportAndGender(req.query.sport, gender)
.then(data => res.json(data));
})
module.exports = router;