mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-15 12:02:06 +00:00
25 lines
858 B
JavaScript
25 lines
858 B
JavaScript
|
|
import IOConfiguration from '../../configuration/ioconfig';
|
||
|
|
import NullClusterClient from '../../io/cluster/nullclusterclient';
|
||
|
|
import Config from '../../config';
|
||
|
|
import CyTubeUtil from '../../utilities';
|
||
|
|
|
||
|
|
export default function initialize(app) {
|
||
|
|
const ioConfig = IOConfiguration.fromOldConfig(Config);
|
||
|
|
const clusterClient = new NullClusterClient(ioConfig);
|
||
|
|
|
||
|
|
app.get('/socketconfig/:channel.json', (req, res) => {
|
||
|
|
if (!req.params.channel || !CyTubeUtil.isValidChannelName(req.params.channel)) {
|
||
|
|
return res.status(400).json({
|
||
|
|
error: `Channel "${req.params.channel}" does not exist.`
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
clusterClient.getSocketURL(req.params.channel).then(url => {
|
||
|
|
res.json({
|
||
|
|
url,
|
||
|
|
secure: /^(https|wss)/.test(url)
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}
|