mirror of https://github.com/Chocobozzz/PeerTube
Implement getServerListeningConfig plugin helper
parent
518c5cc62d
commit
60bab7b540
|
@ -209,6 +209,10 @@ function buildConfigHelpers () {
|
|||
return WEBSERVER.URL
|
||||
},
|
||||
|
||||
getServerListeningConfig () {
|
||||
return { hostname: CONFIG.LISTEN.HOSTNAME, port: CONFIG.LISTEN.PORT }
|
||||
},
|
||||
|
||||
getServerConfig () {
|
||||
return ServerConfigManager.Instance.getServerConfig()
|
||||
}
|
||||
|
|
|
@ -76,6 +76,12 @@ async function register ({
|
|||
return res.json({ serverConfig })
|
||||
})
|
||||
|
||||
router.get('/server-listening-config', async (req, res) => {
|
||||
const config = await peertubeHelpers.config.getServerListeningConfig()
|
||||
|
||||
return res.json({ config })
|
||||
})
|
||||
|
||||
router.get('/static-route', async (req, res) => {
|
||||
const staticRoute = peertubeHelpers.plugin.getBaseStaticRoute()
|
||||
|
||||
|
|
|
@ -64,6 +64,18 @@ describe('Test plugin helpers', function () {
|
|||
await servers[0].servers.waitUntilLog(`server url is ${servers[0].url}`)
|
||||
})
|
||||
|
||||
it('Should have the correct listening config', async function () {
|
||||
const res = await makeGetRequest({
|
||||
url: servers[0].url,
|
||||
path: '/plugins/test-four/router/server-listening-config',
|
||||
expectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
|
||||
expect(res.body.config).to.exist
|
||||
expect(res.body.config.hostname).to.equal('::')
|
||||
expect(res.body.config.port).to.equal(servers[0].port)
|
||||
})
|
||||
|
||||
it('Should have the correct config', async function () {
|
||||
const res = await makeGetRequest({
|
||||
url: servers[0].url,
|
||||
|
|
|
@ -71,6 +71,9 @@ export type PeerTubeHelpers = {
|
|||
config: {
|
||||
getWebserverUrl: () => string
|
||||
|
||||
// PeerTube >= 5.1
|
||||
getServerListeningConfig: () => { hostname: string, port: number }
|
||||
|
||||
getServerConfig: () => Promise<ServerConfig>
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue