Skip to content

Commit

Permalink
Merge branch 'main' into serve-seo-tags-for-the-login-and-signup-page…
Browse files Browse the repository at this point in the history
…s-prerendered
  • Loading branch information
cstns authored Jan 10, 2025
2 parents ff56d58 + 3c9ec14 commit 10eb2b3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions forge/ee/routes/teamBroker/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const schemaApi = require('./schema')

module.exports = async function (app) {
app.addHook('preHandler', app.verifySession)

Expand Down Expand Up @@ -35,6 +37,8 @@ module.exports = async function (app) {
}
})

await schemaApi(app)

/**
* Get the Teams MQTT Clients
* @name /api/v1/teams/:teamId/broker/clients
Expand Down
42 changes: 42 additions & 0 deletions forge/ee/routes/teamBroker/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const YAML = require('yaml')
module.exports = async function (app) {
app.get('/team-broker/schema.yml', async (request, reply) => {
const list = await app.teamBroker.getUsedTopics(request.team.hashid)
const schema = {
asyncapi: '3.0.0',
info: {
version: '1.0.0',
title: `${request.team.name} Team Broker`,
description: 'An auto-generated schema of the topics being used on the team broker'
}
}
// Add the team-broker details

// Figure out the hostname for the team broker
let teamBrokerHost = app.config.broker?.teamBroker?.host
if (!teamBrokerHost) {
// No explict value set, default to broker.${domain}
if (app.config.domain) {
teamBrokerHost = `broker.${app.config.domain}`
}
}
if (teamBrokerHost) {
schema.servers = {
'team-broker': {
host: teamBrokerHost,
protocol: 'mqtt'
}
}
}

if (list.length > 0) {
schema.channels = {}
list.forEach(topic => {
schema.channels[topic] = {
address: topic
}
})
}
reply.send(YAML.stringify(schema))
})
}
5 changes: 5 additions & 0 deletions forge/routes/api/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ module.exports = async function (app) {
if (app.config.features.enabled('customHostnames')) {
response.cnameTarget = app.config.driver.options?.customHostname?.cnameTarget
}
if (app.config.features.enabled('teamBroker')) {
// use IP address if on localfs and no domain configured
const defaultHost = app.config.domain ? `broker.${app.config.domain}` : app.config.host
response['team:broker:host'] = app.config.broker?.teamBroker?.host || defaultHost
}

if (request.session.User.admin) {
response['platform:licensed'] = isLicensed
Expand Down

0 comments on commit 10eb2b3

Please sign in to comment.