1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing ServerTimingMW #437

This commit is contained in:
Patrik J. Braun 2022-02-26 17:33:27 +01:00
parent 41ad14dffd
commit 8469903189

View File

@ -42,6 +42,8 @@ export const ServerTime = (id: string, name: string) => {
};
const forcedDebug = process.env.NODE_ENV === 'debug';
export class ServerTimingMWs {
@ -49,8 +51,8 @@ export class ServerTimingMWs {
* Add server timing
*/
public static async addServerTiming(req: Request, res: Response, next: NextFunction): Promise<any> {
if (Config.Server.Log.logServerTiming === false || !req.timing) {
next();
if ((Config.Server.Log.logServerTiming === false && !forcedDebug) || !req.timing) {
return next();
}
const l = Object.entries(req.timing).filter(e => e[1].endTime).map(e => `${e[0]};dur=${e[1].endTime};desc="${e[1].name}"`);
res.header('Server-Timing', l.join(', '));