Last active
December 7, 2020 20:06
-
-
Save willshepp28/587737133951bf1de76c88b255320262 to your computer and use it in GitHub Desktop.
using getleaguesbyradius to get all leageus within a certain radius.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const router = require("express").Router(); | |
const model = require("../db/models"); | |
const {addLeagueValidator, findLeagueValidator} = require("../helpers/validation/league.validation"); | |
const { findLeagueByName, getLeaguesByRadiusRaw } = require("../services/league/league.service"); | |
// GET path to find a league | |
// Given a total budget, a radius, and a location, this service should return enough leagues to spend up to the budget, sponsoring as many leagues as possible without going over it | |
router.get("/", findLeagueValidator, async(request, response) => { | |
try { | |
const getLeagues = await getLeaguesByRadiusRaw(request); | |
return response.status(200).json(getLeagues); | |
} catch(error){ | |
console.log(error) | |
return response.status(400).json(error); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment