You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
629 B
25 lines
629 B
'use strict';
|
|
|
|
module.exports.initializeProfilerMiddleware = function initializeProfiler (label) {
|
|
return function initializeProfilerMiddleware (req, res, next) {
|
|
if (req.profiler) {
|
|
req.profiler.start(`sqlapi.${label}`);
|
|
}
|
|
|
|
next();
|
|
};
|
|
};
|
|
|
|
module.exports.finishProfilerMiddleware = function finishProfiler () {
|
|
return function finishProfilerMiddleware (req, res, next) {
|
|
if (req.profiler) {
|
|
req.profiler.end();
|
|
req.profiler.sendStats();
|
|
|
|
res.header('X-SQLAPI-Profiler', req.profiler.toJSONString());
|
|
}
|
|
|
|
next();
|
|
};
|
|
};
|