Use ES6 syntax class
This commit is contained in:
parent
fa4ec8378e
commit
298297f2c5
@ -23,14 +23,15 @@ const lastModified = require('../middlewares/last-modified');
|
|||||||
const formatter = require('../middlewares/formatter');
|
const formatter = require('../middlewares/formatter');
|
||||||
const content = require('../middlewares/content');
|
const content = require('../middlewares/content');
|
||||||
|
|
||||||
function QueryController(metadataBackend, userDatabaseService, statsdClient, userLimitsService) {
|
module.exports = class QueryController {
|
||||||
|
constructor (metadataBackend, userDatabaseService, statsdClient, userLimitsService) {
|
||||||
this.metadataBackend = metadataBackend;
|
this.metadataBackend = metadataBackend;
|
||||||
this.stats = statsdClient;
|
this.stats = statsdClient;
|
||||||
this.userDatabaseService = userDatabaseService;
|
this.userDatabaseService = userDatabaseService;
|
||||||
this.userLimitsService = userLimitsService;
|
this.userLimitsService = userLimitsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryController.prototype.route = function (app) {
|
route (app) {
|
||||||
const { base_url } = global.settings;
|
const { base_url } = global.settings;
|
||||||
const forceToBeMaster = false;
|
const forceToBeMaster = false;
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ QueryController.prototype.route = function (app) {
|
|||||||
|
|
||||||
app.all(`${base_url}/sql`, queryMiddlewares());
|
app.all(`${base_url}/sql`, queryMiddlewares());
|
||||||
app.all(`${base_url}/sql.:f`, queryMiddlewares());
|
app.all(`${base_url}/sql.:f`, queryMiddlewares());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleQuery ({ stats } = {}) {
|
function handleQuery ({ stats } = {}) {
|
||||||
@ -113,13 +115,15 @@ function handleQuery ({ stats } = {}) {
|
|||||||
if (req.profiler) {
|
if (req.profiler) {
|
||||||
req.profiler.sendStats();
|
req.profiler.sendStats();
|
||||||
}
|
}
|
||||||
if (statsdClient) {
|
|
||||||
|
if (stats) {
|
||||||
if (err) {
|
if (err) {
|
||||||
stats.increment('sqlapi.query.error');
|
stats.increment('sqlapi.query.error');
|
||||||
} else {
|
} else {
|
||||||
stats.increment('sqlapi.query.success');
|
stats.increment('sqlapi.query.success');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
next(err);
|
next(err);
|
||||||
@ -129,6 +133,4 @@ function handleQuery ({ stats } = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = QueryController;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user