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:
@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_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 StatsClient = require('./app/stats/client');
const StatsClient = require('./lib/stats/client');
if (global.settings.statsd) {
// Perform keyword substitution in statsd
if (global.settings.statsd.prefix) {
@ -86,7 +87,7 @@ if (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 listener = server.listen(global.settings.node_port, global.settings.node_host);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,14 @@
'use strict';
var JobRunner = require('./job_runner');
var QueryRunner = require('./query_runner');
var JobCanceller = require('./job_canceller');
var JobRunner = require('./job-runner');
var QueryRunner = require('./query-runner');
var JobCanceller = require('./job-canceller');
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 JobQueue = require('./job_queue');
var JobBackend = require('./job_backend');
var JobService = require('./job_service');
var JobQueue = require('./job-queue');
var JobBackend = require('./job-backend');
var JobService = require('./job-service');
var BatchLogger = require('./batch-logger');
var Batch = require('./batch');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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