eecs448-project-4/app/routing/routers/api.routes.js

95 lines
3.1 KiB
JavaScript
Raw Normal View History

2020-11-05 03:18:47 +00:00
/*
* API Routes
* -------------------------------------------------------------
* These routes are related to the AJAX API used by the front-end.
*/
const index = {
/*
* Define the prefix applied to each of these routes.
* For example, if prefix is '/auth':
* '/' becomes '/auth'
* '/login' becomes '/auth/login'
*/
prefix: '/api/v1',
/*
* Define middleware that should be applied to all
* routes defined in this file. Middleware should be
* included using its non-prefixed canonical name.
*
* You can pass arguments along to a middleware by
* specifying it as an array where the first element
* is the canonical name of the middleware and the
* second element is the argument passed to the
* handler's test() method.
*/
middleware: [
// Require an authenticated user
'auth:UserOnly',
// Inject the user's team
'InjectUserTeam',
],
/*
* Define GET routes.
* These routes are registered as GET methods.
* Handlers for these routes should be specified as
* an array of canonical references to controller methods
* or middleware that are applied in order.
*/
get: {
// handlers should be a list of either controller:: or middleware:: references
// e.g. middleware::HomeLogger
// e.g. controller::Home.welcome
'/': [
'controller::Home.welcome'
],
2020-11-08 18:34:50 +00:00
// Get information about the user's team
2020-11-05 03:18:47 +00:00
'/my-team': ['controller::Teams.get_my_team'],
2020-11-08 18:34:50 +00:00
// Get a list of the user's team's players
'/my-team/players': ['controller::Teams.get_my_team_players'],
2020-11-08 18:34:50 +00:00
// Get the uesr's team's current lineup
'/my-team/lineup': ['controller::Teams.get_my_team_current_lineup'],
2020-11-08 18:34:50 +00:00
// Get a list of players available to be drafted
'/draft-board/available': ['controller::DraftBoard.get_available_players'],
2020-11-08 18:34:50 +00:00
// Get a list of matchup, grouped by week number
'/matchups': ['controller::Scores.get_weekly_scores'],
2020-11-08 18:34:50 +00:00
// Get the current league standings
'/league-standings': ['controller::Scores.get_league_standings'],
2020-11-08 18:34:50 +00:00
// Get the status of the current user's session, and game play
'/status': ['controller::Home.get_status'],
2020-11-05 03:18:47 +00:00
},
/*
* Define POST routes.
* These routes are registered as POST methods.
* Handlers for these routes should be specified as
* an array of canonical references to controller methods
* or middleware that are applied in order.
*/
post: {
2020-11-08 18:34:50 +00:00
// Save changes to the current user's team
'/my-team': ['controller::Teams.save_my_team'],
2020-11-08 18:34:50 +00:00
// Save the current user's team's lineup
'/my-team/lineup': ['controller::Teams.save_my_team_lineup'],
2020-11-08 18:34:50 +00:00
// Draft the given player to the current user's team
'/draft-board/draft-player': ['controller::DraftBoard.draft_player_to_team'],
2020-11-05 03:18:47 +00:00
},
// You can include other HTTP verbs here.
// Supported ones are: get, post, put, delete, copy, patch
}
module.exports = exports = index