diff --git a/app/controllers/Home.controller.js b/app/controllers/Home.controller.js index 87aa363..8c0549f 100644 --- a/app/controllers/Home.controller.js +++ b/app/controllers/Home.controller.js @@ -7,6 +7,9 @@ const { Controller } = require('libflitter') * are used as handlers for routes specified in the route files. */ class Home extends Controller { + static get services() { + return [...super.services, 'sports_data'] + } /* * Serve the main welcome page. @@ -18,6 +21,15 @@ class Home extends Controller { return res.redirect('/auth/login') } } + + async get_status(req, res, next) { + return res.api({ + team_id: req.user_team.id, + team_name: req.user_team.team_name, + current_week: await this.sports_data.current_play_week(), + is_draft_stage: await this.sports_data.is_draft_stage(), + }) + } } module.exports = Home diff --git a/app/routing/routers/api.routes.js b/app/routing/routers/api.routes.js index 2d45fad..aae9ed8 100644 --- a/app/routing/routers/api.routes.js +++ b/app/routing/routers/api.routes.js @@ -55,6 +55,8 @@ const index = { '/matchups': ['controller::Scores.get_weekly_scores'], '/league-standings': ['controller::Scores.get_league_standings'], + + '/status': ['controller::Home.get_status'], }, /* diff --git a/frontend/src/components/TopLevel.component.js b/frontend/src/components/TopLevel.component.js index c556152..dd13e6e 100644 --- a/frontend/src/components/TopLevel.component.js +++ b/frontend/src/components/TopLevel.component.js @@ -1,5 +1,6 @@ import {Component} from '../../lib/vues6.js' import {router} from '../module/routing.js' +import {api} from '../module/api.js' const template = `