Skip to content

Instantly share code, notes, and snippets.

@willshepp28
Last active December 7, 2020 20:06
Show Gist options
  • Save willshepp28/587737133951bf1de76c88b255320262 to your computer and use it in GitHub Desktop.
Save willshepp28/587737133951bf1de76c88b255320262 to your computer and use it in GitHub Desktop.
using getleaguesbyradius to get all leageus within a certain radius.
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