1.) module dependency updated from jade 1.11.0 to pug 2.0.0-beta3 2.) All references to Jade have been changed to Pug 3.) /srv/web/jade.js is renamed to pug.js 4.) all template files renamed accordingly 5.) "mixin somename" is automatically considered a declaration, invocations must use "+somename" 6.) variable interpolation is no longer supported inside element attributes, use direct references and string concatenation instead. 7.) bumped minor version
26 lines
953 B
JavaScript
26 lines
953 B
JavaScript
import CyTubeUtil from '../../utilities';
|
|
import { sanitizeText } from '../../xss';
|
|
import { sendPug } from '../pug';
|
|
import * as HTTPStatus from '../httpstatus';
|
|
import { HTTPError } from '../../errors';
|
|
|
|
export default function initialize(app, ioConfig) {
|
|
app.get('/r/:channel', (req, res) => {
|
|
if (!req.params.channel || !CyTubeUtil.isValidChannelName(req.params.channel)) {
|
|
throw new HTTPError(`"${sanitizeText(req.params.channel)}" is not a valid ` +
|
|
'channel name.', { status: HTTPStatus.NOT_FOUND });
|
|
}
|
|
|
|
const endpoints = ioConfig.getSocketEndpoints();
|
|
if (endpoints.length === 0) {
|
|
throw new HTTPError('No socket.io endpoints configured');
|
|
}
|
|
const socketBaseURL = endpoints[0].url;
|
|
|
|
sendPug(res, 'channel', {
|
|
channelName: req.params.channel,
|
|
sioSource: `${socketBaseURL}/socket.io/socket.io.js`
|
|
});
|
|
});
|
|
}
|