2020-11-23 13:24:19 -05:00
|
|
|
const log4js = require('log4js');
|
|
|
|
const clientLogger = log4js.getLogger('client');
|
|
|
|
const formidable = require('formidable');
|
|
|
|
const apiHandler = require('../../handler/APIHandler');
|
2012-02-25 15:20:31 +01:00
|
|
|
|
|
|
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
2020-11-23 13:24:19 -05:00
|
|
|
// The Etherpad client side sends information about how a disconnect happened
|
|
|
|
args.app.post('/ep/pad/connection-diagnostic-info', (req, res) => {
|
|
|
|
new formidable.IncomingForm().parse(req, (err, fields, files) => {
|
|
|
|
clientLogger.info(`DIAGNOSTIC-INFO: ${fields.diagnosticInfo}`);
|
|
|
|
res.end('OK');
|
2012-02-25 15:20:31 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-11-23 13:24:19 -05:00
|
|
|
// The Etherpad client side sends information about client side javscript errors
|
|
|
|
args.app.post('/jserror', (req, res) => {
|
|
|
|
new formidable.IncomingForm().parse(req, (err, fields, files) => {
|
2013-10-10 18:45:22 +02:00
|
|
|
try {
|
2020-11-23 13:24:19 -05:00
|
|
|
var data = JSON.parse(fields.errorInfo);
|
|
|
|
} catch (e) {
|
|
|
|
return res.end();
|
2013-10-10 18:45:22 +02:00
|
|
|
}
|
2020-11-23 13:24:19 -05:00
|
|
|
clientLogger.warn(`${data.msg} --`, data);
|
|
|
|
res.end('OK');
|
2012-02-25 15:20:31 +01:00
|
|
|
});
|
|
|
|
});
|
2018-03-23 11:17:39 +00:00
|
|
|
|
2020-11-23 13:24:19 -05:00
|
|
|
// Provide a possibility to query the latest available API version
|
|
|
|
args.app.get('/api', (req, res) => {
|
|
|
|
res.json({currentVersion: apiHandler.latestApiVersion});
|
2013-02-12 21:47:40 +01:00
|
|
|
});
|
2020-10-10 22:51:26 -04:00
|
|
|
|
|
|
|
return cb();
|
2020-11-23 13:24:19 -05:00
|
|
|
};
|