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:
parent
41ad14dffd
commit
8469903189
@ -42,6 +42,8 @@ export const ServerTime = (id: string, name: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const forcedDebug = process.env.NODE_ENV === 'debug';
|
||||||
|
|
||||||
export class ServerTimingMWs {
|
export class ServerTimingMWs {
|
||||||
|
|
||||||
|
|
||||||
@ -49,8 +51,8 @@ export class ServerTimingMWs {
|
|||||||
* Add server timing
|
* Add server timing
|
||||||
*/
|
*/
|
||||||
public static async addServerTiming(req: Request, res: Response, next: NextFunction): Promise<any> {
|
public static async addServerTiming(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||||
if (Config.Server.Log.logServerTiming === false || !req.timing) {
|
if ((Config.Server.Log.logServerTiming === false && !forcedDebug) || !req.timing) {
|
||||||
next();
|
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}"`);
|
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(', '));
|
res.header('Server-Timing', l.join(', '));
|
||||||
|
Loading…
Reference in New Issue
Block a user