// Two "no state to speak of" endpoints: // GET /status — bare liveness probe (no auth). // GET /CollabCentral/:app/info — bot metadata + session flags used // by the frontend bootstrap to decide // which page shell to render. // // registerInfoRoutes(app, { getBotProfile, isAuthorized, isAdmin }) export function registerInfoRoutes(app, deps) { var getBotProfile = deps.getBotProfile; var isAuthorized = deps.isAuthorized; var isAdmin = deps.isAdmin; app.get('/status', function (req, res) { res.status(200).send({ status: "I'm alive!'" }); }); // Returns the bot's display metadata + whether the current cookie is // authorized. The front-end uses this to drive page labels, icons, // and the "you don't have access" view, so adding a new bot doesn't // require any code changes in the HTML/JS. app.get('/CollabCentral/:app/info', function (req, res) { var appName = req.params.app; var botCfg = req.botConfig; // populated by requireBot var profile = getBotProfile(appName) || {}; var iconBase = botCfg.iconBase || appName; var personId = req.cookies && req.cookies.id; res.status(200).send({ appName: appName, label: botCfg.label || appName, displayName: profile.displayName || botCfg.label || appName, iconUrl: '/CollabCentral/' + appName + '/' + iconBase + '.png', faviconUrl: '/CollabCentral/' + appName + '/' + iconBase + '.ico', avatarUrl: profile.avatar || null, authorized: isAuthorized(appName, personId), isAdmin: isAdmin(personId) }); }); }