Changed folder structure to reflect application functionallity. Renamed files using hyphens instead of underscore to have a more consistent naming across the whole project

This commit is contained in:
Daniel García Aubert 2019-10-03 18:24:39 +02:00
parent b5bb06db6c
commit 06a47a8afc
198 changed files with 241 additions and 235 deletions

View File

@ -11,7 +11,7 @@ check:
jshint: jshint:
@echo "***jshint***" @echo "***jshint***"
@./node_modules/.bin/jshint app/ batch/ test/ app.js @./node_modules/.bin/jshint lib/ test/ app.js
TEST_SUITE := $(shell find test/{unit,integration,acceptance} -name "*.js") TEST_SUITE := $(shell find test/{unit,integration,acceptance} -name "*.js")
TEST_SUITE_UNIT := $(shell find test/unit -name "*.js") TEST_SUITE_UNIT := $(shell find test/unit -name "*.js")

5
app.js
View File

@ -77,7 +77,8 @@ if (!global.settings.routes) {
const version = require("./package").version; const version = require("./package").version;
const StatsClient = require('./app/stats/client'); const StatsClient = require('./lib/stats/client');
if (global.settings.statsd) { if (global.settings.statsd) {
// Perform keyword substitution in statsd // Perform keyword substitution in statsd
if (global.settings.statsd.prefix) { if (global.settings.statsd.prefix) {
@ -86,7 +87,7 @@ if (global.settings.statsd) {
} }
const statsClient = StatsClient.getInstance(global.settings.statsd); const statsClient = StatsClient.getInstance(global.settings.statsd);
const createServer = require('./app/server'); const createServer = require('./lib/server');
const server = createServer(statsClient); const server = createServer(statsClient);
const listener = server.listen(global.settings.node_port, global.settings.node_host); const listener = server.listen(global.settings.node_port, global.settings.node_host);

View File

@ -2,19 +2,19 @@
const { Router: router } = require('express'); const { Router: router } = require('express');
const SqlRouter = require('./sql-router'); const SqlRouter = require('./sql/sql-router');
const HealthCheckController = require('./health_check_controller'); const HealthCheckController = require('./health-check-controller');
const VersionController = require('./version_controller'); const VersionController = require('./version-controller');
const JobsWipController = require('./jobs_wip_controller'); const JobsWipController = require('./jobs-wip-controller');
const BatchLogger = require('../../batch/batch-logger'); const BatchLogger = require('../batch/batch-logger');
const JobPublisher = require('../../batch/pubsub/job-publisher'); const JobPublisher = require('../batch/pubsub/job-publisher');
const JobQueue = require('../../batch/job_queue'); const JobQueue = require('../batch/job-queue');
const JobBackend = require('../../batch/job_backend'); const JobBackend = require('../batch/job-backend');
const JobCanceller = require('../../batch/job_canceller'); const JobCanceller = require('../batch/job-canceller');
const JobService = require('../../batch/job_service'); const JobService = require('../batch/job-service');
module.exports = class ApiRouter { module.exports = class ApiRouter {
constructor ({ redisPool, metadataBackend, statsClient, dataIngestionLogger }) { constructor ({ redisPool, metadataBackend, statsClient, dataIngestionLogger }) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const HealthCheckBackend = require('../monitoring/health_check'); const HealthCheckBackend = require('../monitoring/health-check');
module.exports = class HealthCheckController { module.exports = class HealthCheckController {
constructor () { constructor () {

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const bodyParserMiddleware = require('../middlewares/body-parser'); const bodyParserMiddleware = require('./middlewares/body-parser');
const errorMiddleware = require('../middlewares/error'); const errorMiddleware = require('./middlewares/error');
module.exports = class JobsWipController { module.exports = class JobsWipController {
constructor ({ jobService }) { constructor ({ jobService }) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const pgEntitiesAccessValidator = require('../services/pg-entities-access-validator'); const pgEntitiesAccessValidator = require('../../services/pg-entities-access-validator');
module.exports = function accessValidator () { module.exports = function accessValidator () {
return function accessValidatorMiddleware (req, res, next) { return function accessValidatorMiddleware (req, res, next) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const AuthApi = require('../auth/auth_api'); const AuthApi = require('../../auth/auth-api');
const basicAuth = require('basic-auth'); const basicAuth = require('basic-auth');
module.exports = function authorization (metadataBackend, forceToBeMaster = false) { module.exports = function authorization (metadataBackend, forceToBeMaster = false) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const getContentDisposition = require('../utils/content_disposition'); const getContentDisposition = require('../../utils/content-disposition');
module.exports = function content () { module.exports = function content () {
return function contentMiddleware (req, res, next) { return function contentMiddleware (req, res, next) {

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const errorHandlerFactory = require('../services/error_handler_factory'); const errorHandlerFactory = require('../../services/error-handler-factory');
const { stringifyForLogs } = require('../utils/logs'); const { stringifyForLogs } = require('../../utils/logs');
const MAX_ERROR_STRING_LENGTH = 1024; const MAX_ERROR_STRING_LENGTH = 1024;
module.exports = function error() { module.exports = function error() {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const formats = require('../models/formats'); const formats = require('../../models/formats');
module.exports = function formatter () { module.exports = function formatter () {
return function formatterMiddleware (req, res, next) { return function formatterMiddleware (req, res, next) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { stringifyForLogs } = require('../utils/logs'); const { stringifyForLogs } = require('../../utils/logs');
const MAX_SQL_LENGTH = (global.settings.logQueries && global.settings.maxQueriesLogLength) || 1024; const MAX_SQL_LENGTH = (global.settings.logQueries && global.settings.maxQueriesLogLength) || 1024;

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const sanitizeFilename = require('../utils/filename_sanitizer'); const sanitizeFilename = require('../../utils/filename-sanitizer');
const formats = require('../models/formats'); const formats = require('../../models/formats');
module.exports = function params ({ strategy = 'query' } = {}) { module.exports = function params ({ strategy = 'query' } = {}) {
const getParams = getParamsFromStrategy(strategy); const getParams = getParamsFromStrategy(strategy);

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const Profiler = require('../stats/profiler-proxy'); const Profiler = require('../../stats/profiler-proxy');
module.exports = function profiler ({ statsClient }) { module.exports = function profiler ({ statsClient }) {
return function profilerMiddleware (req, res, next) { return function profilerMiddleware (req, res, next) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const queryMayWrite = require('../utils/query_may_write'); const queryMayWrite = require('../../utils/query-may-write');
module.exports = function mayWrite () { module.exports = function mayWrite () {
return function mayWriteMiddleware (req, res, next) { return function mayWriteMiddleware (req, res, next) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const CdbRequest = require('../models/cartodb_request'); const CdbRequest = require('../../models/cartodb-request');
module.exports = function user(metadataBackend) { module.exports = function user(metadataBackend) {
const cdbRequest = new CdbRequest(); const cdbRequest = new CdbRequest();

View File

@ -8,10 +8,10 @@ const { initializeProfilerMiddleware } = require('../middlewares/profiler');
const rateLimitsMiddleware = require('../middlewares/rate-limit'); const rateLimitsMiddleware = require('../middlewares/rate-limit');
const dbQuotaMiddleware = require('../middlewares/db-quota'); const dbQuotaMiddleware = require('../middlewares/db-quota');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitsMiddleware; const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitsMiddleware;
const errorHandlerFactory = require('../services/error_handler_factory'); const errorHandlerFactory = require('../../services/error-handler-factory');
const StreamCopy = require('../services/stream_copy'); const StreamCopy = require('../../services/stream-copy');
const StreamCopyMetrics = require('../services/stream_copy_metrics'); const StreamCopyMetrics = require('../../services/stream-copy-metrics');
const Throttler = require('../services/throttler-stream'); const Throttler = require('../../services/throttler-stream');
const zlib = require('zlib'); const zlib = require('zlib');
const { PassThrough } = require('stream'); const { PassThrough } = require('stream');
const params = require('../middlewares/params'); const params = require('../middlewares/params');

View File

@ -2,8 +2,8 @@
const { Router: router } = require('express'); const { Router: router } = require('express');
const UserDatabaseService = require('../services/user_database_service'); const UserDatabaseService = require('../../services/user-database-service');
const UserLimitsService = require('../services/user_limits'); const UserLimitsService = require('../../services/user-limits');
const socketTimeout = require('../middlewares/socket-timeout'); const socketTimeout = require('../middlewares/socket-timeout');
const logger = require('../middlewares/logger'); const logger = require('../middlewares/logger');
@ -11,9 +11,9 @@ const profiler = require('../middlewares/profiler');
const cors = require('../middlewares/cors'); const cors = require('../middlewares/cors');
const servedByHostHeader = require('../middlewares/served-by-host-header'); const servedByHostHeader = require('../middlewares/served-by-host-header');
const QueryController = require('./query_controller'); const QueryController = require('./query-controller');
const CopyController = require('./copy_controller'); const CopyController = require('./copy-controller');
const JobController = require('./job_controller'); const JobController = require('./job-controller');
module.exports = class SqlRouter { module.exports = class SqlRouter {
constructor ({ routes, metadataBackend, statsClient, dataIngestionLogger, jobService }) { constructor ({ routes, metadataBackend, statsClient, dataIngestionLogger, jobService }) {

View File

@ -4,7 +4,7 @@
var _ = require('underscore'); var _ = require('underscore');
var OAuthUtil = require('oauth-client'); var OAuthUtil = require('oauth-client');
var step = require('step'); var step = require('step');
var CdbRequest = require('../models/cartodb_request'); var CdbRequest = require('../models/cartodb-request');
var cdbReq = new CdbRequest(); var cdbReq = new CdbRequest();
var oAuth = (function(){ var oAuth = (function(){

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const Logger = require('../app/services/logger'); const Logger = require('../services/logger');
class BatchLogger extends Logger { class BatchLogger extends Logger {
constructor (path, name) { constructor (path, name) {
@ -10,7 +10,6 @@ class BatchLogger extends Logger {
log (job) { log (job) {
return job.log(this.logger); return job.log(this.logger);
} }
} }
module.exports = BatchLogger; module.exports = BatchLogger;

View File

@ -1,14 +1,14 @@
'use strict'; 'use strict';
var JobRunner = require('./job_runner'); var JobRunner = require('./job-runner');
var QueryRunner = require('./query_runner'); var QueryRunner = require('./query-runner');
var JobCanceller = require('./job_canceller'); var JobCanceller = require('./job-canceller');
var JobSubscriber = require('./pubsub/job-subscriber'); var JobSubscriber = require('./pubsub/job-subscriber');
var UserDatabaseMetadataService = require('./user_database_metadata_service'); var UserDatabaseMetadataService = require('./user-database-metadata-service');
var JobPublisher = require('./pubsub/job-publisher'); var JobPublisher = require('./pubsub/job-publisher');
var JobQueue = require('./job_queue'); var JobQueue = require('./job-queue');
var JobBackend = require('./job_backend'); var JobBackend = require('./job-backend');
var JobService = require('./job_service'); var JobService = require('./job-service');
var BatchLogger = require('./batch-logger'); var BatchLogger = require('./batch-logger');
var Batch = require('./batch'); var Batch = require('./batch');

View File

@ -2,7 +2,7 @@
var REDIS_PREFIX = 'batch:jobs:'; var REDIS_PREFIX = 'batch:jobs:';
var REDIS_DB = 5; var REDIS_DB = 5;
var JobStatus = require('./job_status'); var JobStatus = require('./job-status');
var queue = require('queue-async'); var queue = require('queue-async');
function JobBackend(metadataBackend, jobQueue, logger) { function JobBackend(metadataBackend, jobQueue, logger) {

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var errorCodes = require('../app/postgresql/error_codes').codeToCondition; var errorCodes = require('../postgresql/error-codes').codeToCondition;
var jobStatus = require('./job_status'); var jobStatus = require('./job-status');
var Profiler = require('step-profiler'); var Profiler = require('step-profiler');
var _ = require('underscore'); var _ = require('underscore');

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var JobFactory = require('./models/job_factory'); var JobFactory = require('./models/job-factory');
var jobStatus = require('./job_status'); var jobStatus = require('./job-status');
function JobService(jobBackend, jobCanceller, logger) { function JobService(jobBackend, jobCanceller, logger) {
this.jobBackend = jobBackend; this.jobBackend = jobBackend;

View File

@ -2,8 +2,8 @@
var util = require('util'); var util = require('util');
var uuid = require('node-uuid'); var uuid = require('node-uuid');
var JobStateMachine = require('./job_state_machine'); var JobStateMachine = require('./job-state-machine');
var jobStatus = require('../job_status'); var jobStatus = require('../job-status');
var mandatoryProperties = [ var mandatoryProperties = [
'job_id', 'job_id',
'status', 'status',

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var JobSimple = require('./job_simple'); var JobSimple = require('./job-simple');
var JobMultiple = require('./job_multiple'); var JobMultiple = require('./job-multiple');
var JobFallback = require('./job_fallback'); var JobFallback = require('./job-fallback');
var Models = [ JobSimple, JobMultiple, JobFallback ]; var Models = [ JobSimple, JobMultiple, JobFallback ];

View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var JobBase = require('./job_base'); var JobBase = require('./job-base');
var JobStatus = require('../job_status'); var JobStatus = require('../job-status');
var QueryFallback = require('./query/query_fallback'); var QueryFallback = require('./query/query-fallback');
var MainFallback = require('./query/main_fallback'); var MainFallback = require('./query/main-fallback');
var QueryFactory = require('./query/query_factory'); var QueryFactory = require('./query/query-factory');
function JobFallback(jobDefinition) { function JobFallback(jobDefinition) {
JobBase.call(this, jobDefinition); JobBase.call(this, jobDefinition);

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var JobBase = require('./job_base'); var JobBase = require('./job-base');
var jobStatus = require('../job_status'); var jobStatus = require('../job-status');
function JobMultiple(jobDefinition) { function JobMultiple(jobDefinition) {
JobBase.call(this, jobDefinition); JobBase.call(this, jobDefinition);

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var JobBase = require('./job_base'); var JobBase = require('./job-base');
var jobStatus = require('../job_status'); var jobStatus = require('../job-status');
function JobSimple(jobDefinition) { function JobSimple(jobDefinition) {
JobBase.call(this, jobDefinition); JobBase.call(this, jobDefinition);

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var assert = require('assert'); var assert = require('assert');
var JobStatus = require('../job_status'); var JobStatus = require('../job-status');
var validStatusTransitions = [ var validStatusTransitions = [
[JobStatus.PENDING, JobStatus.RUNNING], [JobStatus.PENDING, JobStatus.RUNNING],
[JobStatus.PENDING, JobStatus.CANCELLED], [JobStatus.PENDING, JobStatus.CANCELLED],

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var QueryBase = require('./query_base'); var QueryBase = require('./query-base');
var jobStatus = require('../../job_status'); var jobStatus = require('../../job-status');
function Fallback(index) { function Fallback(index) {
QueryBase.call(this, index); QueryBase.call(this, index);

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var QueryBase = require('./query_base'); var QueryBase = require('./query-base');
var jobStatus = require('../../job_status'); var jobStatus = require('../../job-status');
function MainFallback() { function MainFallback() {
QueryBase.call(this); QueryBase.call(this);

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var JobStateMachine = require('../job_state_machine'); var JobStateMachine = require('../job-state-machine');
function QueryBase(index) { function QueryBase(index) {
JobStateMachine.call(this); JobStateMachine.call(this);

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
var QueryFallback = require('./query_fallback'); var QueryFallback = require('./query-fallback');
function QueryFactory() { function QueryFactory() {
} }

View File

@ -1,10 +1,10 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var QueryBase = require('./query_base'); var QueryBase = require('./query-base');
var Query = require('./query'); var Query = require('./query');
var Fallback = require('./fallback'); var Fallback = require('./fallback');
var jobStatus = require('../../job_status'); var jobStatus = require('../../job-status');
function QueryFallback(job, index) { function QueryFallback(job, index) {
QueryBase.call(this, index); QueryBase.call(this, index);

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var util = require('util'); var util = require('util');
var QueryBase = require('./query_base'); var QueryBase = require('./query-base');
var jobStatus = require('../../job_status'); var jobStatus = require('../../job-status');
function Query(index) { function Query(index) {
QueryBase.call(this, index); QueryBase.call(this, index);

View File

@ -3,7 +3,7 @@
var _ = require('underscore'); var _ = require('underscore');
var Pg = require('./../pg'); var Pg = require('./../pg');
var ArrayBufferSer = require("../../bin_encoder"); var ArrayBufferSer = require("../../bin-encoder");
function BinaryFormat() {} function BinaryFormat() {}

View File

@ -3,7 +3,7 @@
var _ = require('underscore'); var _ = require('underscore');
var Pg = require('./../pg'); var Pg = require('./../pg');
const errorHandlerFactory = require('../../../services/error_handler_factory'); const errorHandlerFactory = require('../../../services/error-handler-factory');
function GeoJsonFormat() { function GeoJsonFormat() {
this.buffer = ''; this.buffer = '';

View File

@ -3,7 +3,7 @@
var _ = require('underscore'); var _ = require('underscore');
var Pg = require('./../pg'); var Pg = require('./../pg');
const errorHandlerFactory = require('../../../services/error_handler_factory'); const errorHandlerFactory = require('../../../services/error-handler-factory');
function JsonFormat() { function JsonFormat() {
this.buffer = ''; this.buffer = '';

View File

@ -1,5 +1,7 @@
'use strict'; 'use strict';
// jshint ignore:start
var Pg = require('./../pg'); var Pg = require('./../pg');
var _ = require('underscore'); var _ = require('underscore');
var geojson = require('./geojson'); var geojson = require('./geojson');
@ -133,6 +135,6 @@ TopoJsonFormat.prototype.cancel = function() {
} }
}; };
module.exports = TopoJsonFormat; module.exports = TopoJsonFormat;
// jshint ignore:end

View File

@ -6,14 +6,14 @@ const mkdirp = require('mkdirp');
const RedisPool = require('redis-mpool'); const RedisPool = require('redis-mpool');
const cartodbRedis = require('cartodb-redis'); const cartodbRedis = require('cartodb-redis');
const Logger = require('./services/logger'); const Logger = require('./services/logger');
const ApiRouter = require('./controllers/api-router'); const ApiRouter = require('./api/api-router');
const batchFactory = require('../batch'); const batchFactory = require('./batch');
const getServerOptions = require('./server-options'); const getServerOptions = require('./server-options');
process.env.PGAPPNAME = process.env.PGAPPNAME || 'cartodb_sqlapi'; process.env.PGAPPNAME = process.env.PGAPPNAME || 'cartodb_sqlapi';
// override Date.toJSON // override Date.toJSON
require('./utils/date_to_json'); require('./utils/date-to-json');
// jshint maxcomplexity:9 // jshint maxcomplexity:9
module.exports = function createServer (statsClient) { module.exports = function createServer (statsClient) {

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const ErrorHandler = require('./error_handler'); const ErrorHandler = require('./error-handler');
const { codeToCondition } = require('../postgresql/error_codes'); const { codeToCondition } = require('../postgresql/error-codes');
module.exports = function ErrorHandlerFactory (err) { module.exports = function ErrorHandlerFactory (err) {
if (isTimeoutError(err)) { if (isTimeoutError(err)) {

Some files were not shown because too many files have changed in this diff Show More