bigbluebutton-Github/bigbluebutton-html5/imports/startup/server/index.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-10-22 00:27:47 +08:00
import { Meteor } from 'meteor/meteor';
2017-03-10 03:50:21 +08:00
import _ from 'lodash';
2016-10-18 20:03:51 +08:00
import Logger from './logger';
import Redis from './redis';
2016-10-18 20:03:51 +08:00
Meteor.startup(() => {
const APP_CONFIG = Meteor.settings.public.app;
2016-10-22 00:27:47 +08:00
Logger.info(`SERVER STARTED. ENV=${Meteor.settings.runtime.env}`, APP_CONFIG);
});
2016-06-14 01:56:41 +08:00
WebApp.connectHandlers.use('/check', (req, res, next) => {
let payload = { html5clientStatus: 'running' };
res.setHeader('Content-Type', 'application/json');
res.writeHead(200);
res.end(JSON.stringify(payload));
});
WebApp.connectHandlers.use('/locale', (req, res) => {
2017-03-10 03:50:21 +08:00
const APP_CONFIG = Meteor.settings.public.app;
let defaultLocale = APP_CONFIG.defaultLocale;
let localeRegion = _.snakeCase(req.query.locale).split('_');
let messages = {};
2017-03-11 03:18:23 +08:00
let locales = [defaultLocale, localeRegion[0]];
2017-03-10 03:50:21 +08:00
if (localeRegion.length > 1) {
locales.push(`${localeRegion[0]}_${localeRegion[1]}`);
}
locales.forEach(locale => {
try {
const data = Assets.getText(`locales/${locale}.json`);
messages = Object.assign(messages, JSON.parse(data));
} catch (e) {
// console.error(e);
// We dont really care about those errors since they will be a parse error
// or a file not found which is ok
}
});
res.setHeader('Content-Type', 'application/json');
res.writeHead(200);
2016-10-13 01:03:10 +08:00
res.end(JSON.stringify(messages));
});
2016-10-18 20:03:51 +08:00
export const eventEmitter = Redis.emitter;
2016-10-18 20:03:51 +08:00
export let redisPubSub = Redis;