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