using the new TYPES

This commit is contained in:
Simon Martín 2019-02-28 11:49:05 +01:00
parent a97c25e914
commit 52e4dfa728
3 changed files with 11 additions and 6 deletions

View File

@ -45,7 +45,7 @@ JobController.prototype.route = function (app) {
bodyParserMiddleware(), bodyParserMiddleware(),
checkBodyPayloadSize(), checkBodyPayloadSize(),
handleQueryMiddleware(true), handleQueryMiddleware(true),
logMiddleware(), logMiddleware(logMiddleware.TYPES.JOB),
jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE) jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE)
); );
app.get( app.get(

View File

@ -47,7 +47,7 @@ QueryController.prototype.route = function (app) {
connectionParamsMiddleware(this.userDatabaseService), connectionParamsMiddleware(this.userDatabaseService),
timeoutLimitsMiddleware(this.metadataBackend), timeoutLimitsMiddleware(this.metadataBackend),
handleQueryMiddleware(), handleQueryMiddleware(),
logMiddleware(), logMiddleware(logMiddleware.TYPES.QUERY),
this.handleQuery.bind(this), this.handleQuery.bind(this),
errorMiddleware() errorMiddleware()
]; ];

View File

@ -6,6 +6,7 @@ const server = require('../../app/server')();
const assert = require('../support/assert'); const assert = require('../support/assert');
const qs = require('querystring'); const qs = require('querystring');
const BatchTestClient = require('../support/batch-test-client'); const BatchTestClient = require('../support/batch-test-client');
const { TYPES } = require('../../app/middlewares/log');
const QUERY = `SELECT 14 as foo`; const QUERY = `SELECT 14 as foo`;
const API_KEY = 1234; const API_KEY = 1234;
@ -73,7 +74,8 @@ describe('Log middleware', function() {
assert.deepEqual(log, { assert.deepEqual(log, {
request: { request: {
sql: { sql: {
simple: QUERY type: TYPES.QUERY,
sql: QUERY
} }
} }
}); });
@ -104,7 +106,8 @@ describe('Log middleware', function() {
assert.deepEqual(log, { assert.deepEqual(log, {
request: { request: {
sql: { sql: {
simple: QUERY type: TYPES.JOB,
sql: QUERY
} }
} }
}); });
@ -123,7 +126,8 @@ describe('Log middleware', function() {
assert.deepEqual(log, { assert.deepEqual(log, {
request: { request: {
sql: { sql: {
multiple: [QUERY, QUERY] type: TYPES.JOB,
sql: [QUERY, QUERY]
} }
} }
}); });
@ -202,7 +206,8 @@ describe('Log middleware', function() {
assert.deepEqual(log, { assert.deepEqual(log, {
request: { request: {
sql: { sql: {
simple: QUERY.substring(0, global.settings.maxQueriesLogLength) type: TYPES.QUERY.substring(0, global.settings.maxQueriesLogLength),
sql: QUERY.substring(0, global.settings.maxQueriesLogLength)
} }
} }
}); });