Compare commits
3 Commits
develop
...
fix-expres
Author | SHA1 | Date |
---|---|---|
Richard Hansen | 66a7cf73d8 | |
Richard Hansen | 30e5bffaf2 | |
Richard Hansen | 1434129a7b |
|
@ -74,12 +74,6 @@
|
||||||
"expressCreateServer": "ep_etherpad-lite/node/hooks/express/importexport"
|
"expressCreateServer": "ep_etherpad-lite/node/hooks/express/importexport"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "errorhandling",
|
|
||||||
"hooks": {
|
|
||||||
"expressCreateServer": "ep_etherpad-lite/node/hooks/express/errorhandling"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "socketio",
|
"name": "socketio",
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
const assert = require('assert').strict;
|
||||||
const cookieParser = require('cookie-parser');
|
const cookieParser = require('cookie-parser');
|
||||||
const events = require('events');
|
const events = require('events');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
@ -113,6 +114,13 @@ exports.restartServer = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
|
// This stats logic should be in the first middleware to ensure that no other middleware can
|
||||||
|
// prevent the stats from being updated.
|
||||||
|
res.on('finish', () => {
|
||||||
|
assert(res.statusCode);
|
||||||
|
stats.meter(`http${res.statusCode}`).mark();
|
||||||
|
});
|
||||||
|
|
||||||
// res.header("X-Frame-Options", "deny"); // breaks embedded pads
|
// res.header("X-Frame-Options", "deny"); // breaks embedded pads
|
||||||
if (settings.ssl) {
|
if (settings.ssl) {
|
||||||
// we use SSL
|
// we use SSL
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const stats = require('../../stats');
|
|
||||||
|
|
||||||
exports.expressCreateServer = (hook_name, args, cb) => {
|
|
||||||
exports.app = args.app;
|
|
||||||
|
|
||||||
// Handle errors
|
|
||||||
args.app.use((err, req, res, next) => {
|
|
||||||
// if an error occurs Connect will pass it down
|
|
||||||
// through these "error-handling" middleware
|
|
||||||
// allowing you to respond however you like
|
|
||||||
res.status(500).send({error: 'Sorry, something bad happened!'});
|
|
||||||
console.error(err.stack ? err.stack : err.toString());
|
|
||||||
stats.meter('http500').mark();
|
|
||||||
});
|
|
||||||
|
|
||||||
return cb();
|
|
||||||
};
|
|
Loading…
Reference in New Issue