etherpad-lite/src/node/hooks/express/apicalls.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2012-02-25 15:20:31 +01:00
var log4js = require('log4js');
var clientLogger = log4js.getLogger("client");
2012-02-25 15:20:31 +01:00
var formidable = require('formidable');
var apiHandler = require('../../handler/APIHandler');
2012-02-25 15:20:31 +01:00
exports.expressCreateServer = function (hook_name, args, cb) {
//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) {
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) {
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
//Provide a possibility to query the latest available API version
args.app.get('/api', function (req, res) {
res.json({"currentVersion" : apiHandler.latestApiVersion});
});
2012-04-07 15:25:37 +02:00
}