Skip to content

Commit

Permalink
fix: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Mar 14, 2024
1 parent 1198ae1 commit 30eb066
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 74 deletions.
18 changes: 9 additions & 9 deletions src/controllers/bulkUpload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable global-require, import/no-dynamic-require, @typescript-eslint/no-unused-vars */
import customLogger from "@rudderstack/integrations-lib/build/structured-logger";
import { client as errNotificationClient } from '../util/errorNotifier';
import logger from '@rudderstack/integrations-lib';
import { CatchErr, ContextBodySimple } from '../util/types';
// TODO: To be refactored and redisgned

Expand Down Expand Up @@ -31,7 +31,7 @@ const getReqMetadata = (ctx) => {
};

export const fileUpload = async (ctx) => {
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request to transformer:: /fileUpload route',
JSON.stringify(ctx.request.body),
);
Expand Down Expand Up @@ -69,15 +69,15 @@ export const fileUpload = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Response from transformer:: /fileUpload route',
JSON.stringify(ctx.body),
);
return ctx.body;
};

export const pollStatus = async (ctx) => {
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request to transformer:: /pollStatus route',
JSON.stringify(ctx.request.body),
);
Expand All @@ -104,15 +104,15 @@ export const pollStatus = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request from transformer:: /pollStatus route',
JSON.stringify(ctx.body),
);
return ctx.body;
};

export const getWarnJobStatus = async (ctx) => {
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request to transformer:: /getWarningJobs route',
JSON.stringify(ctx.request.body),
);
Expand Down Expand Up @@ -140,15 +140,15 @@ export const getWarnJobStatus = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request from transformer:: /getWarningJobs route',
JSON.stringify(ctx.body),
);
return ctx.body;
};

export const getFailedJobStatus = async (ctx) => {
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request to transformer:: /getFailedJobs route',
JSON.stringify(ctx.request.body),
);
Expand Down Expand Up @@ -176,7 +176,7 @@ export const getFailedJobStatus = async (ctx) => {
});
}
ctx.body = response;
logger.debug(
customLogger.debug(
'Native(Bulk-Upload): Request from transformer:: /getFailedJobs route',
JSON.stringify(ctx.body),
);
Expand Down
14 changes: 7 additions & 7 deletions src/controllers/delivery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable sonarjs/no-duplicate-string */
import { Context } from 'koa';
import customLogger from "@rudderstack/integrations-lib/build/structured-logger";
import { MiscService } from '../services/misc';
import {
DeliveriesResponse,
Expand All @@ -12,7 +13,6 @@ import {
import { ServiceSelector } from '../helpers/serviceSelector';
import { DeliveryTestService } from '../services/delivertTest/deliveryTest';
import { ControllerUtility } from './util';
import logger from '@rudderstack/integrations-lib';
import { DestinationPostTransformationService } from '../services/destination/postTransformation';
import tags from '../v0/util/tags';
import { FixMe } from '../util/types';
Expand All @@ -21,7 +21,7 @@ const NON_DETERMINABLE = 'Non-determinable';

export class DeliveryController {
public static async deliverToDestination(ctx: Context) {
logger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body));
customLogger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body));
let deliveryResponse: DeliveryResponse;
const requestMetadata = MiscService.getRequestMetadata(ctx);
const deliveryRequest = ctx.request.body as ProxyDeliveryRequest;
Expand Down Expand Up @@ -51,12 +51,12 @@ export class DeliveryController {
ctx.body = { output: deliveryResponse };
ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status);

logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
customLogger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
return ctx;
}

public static async deliverToDestinationV1(ctx: Context) {
logger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body));
customLogger.debug('Native(Delivery):: Request to transformer::', JSON.stringify(ctx.request.body));
let deliveryResponse: DeliveriesResponse;
const requestMetadata = MiscService.getRequestMetadata(ctx);
const deliveryRequest = ctx.request.body as ProxyDeliveriesRequest;
Expand Down Expand Up @@ -86,12 +86,12 @@ export class DeliveryController {
ctx.body = { output: deliveryResponse };
ControllerUtility.deliveryPostProcess(ctx, deliveryResponse.status);

logger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
customLogger.debug('Native(Delivery):: Response from transformer::', JSON.stringify(ctx.body));
return ctx;
}

public static async testDestinationDelivery(ctx: Context) {
logger.debug(
customLogger.debug(
'Native(Delivery-Test):: Request to transformer::',
JSON.stringify(ctx.request.body),
);
Expand All @@ -112,7 +112,7 @@ export class DeliveryController {
);
ctx.body = { output: response };
ControllerUtility.postProcess(ctx);
logger.debug('Native(Delivery-Test):: Response from transformer::', JSON.stringify(ctx.body));
customLogger.debug('Native(Delivery-Test):: Response from transformer::', JSON.stringify(ctx.body));
return ctx;
}
}
14 changes: 7 additions & 7 deletions src/controllers/destination.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Context } from 'koa';
import customLogger from "@rudderstack/integrations-lib/build/structured-logger";
import { MiscService } from '../services/misc';
import { DestinationPreTransformationService } from '../services/destination/preTransformation';
import { DestinationPostTransformationService } from '../services/destination/postTransformation';
Expand All @@ -11,15 +12,14 @@ import {
import { ServiceSelector } from '../helpers/serviceSelector';
import { ControllerUtility } from './util';
import stats from '../util/stats';
import logger from '@rudderstack/integrations-lib';
import { getIntegrationVersion } from '../util/utils';
import tags from '../v0/util/tags';
import { DynamicConfigParser } from '../util/dynamicConfigParser';

export class DestinationController {
public static async destinationTransformAtProcessor(ctx: Context) {
const startTime = new Date();
logger.debug(
customLogger.debug(
'Native(Process-Transform):: Requst to transformer::',
JSON.stringify(ctx.request.body),
);
Expand Down Expand Up @@ -68,7 +68,7 @@ export class DestinationController {
}
ctx.body = resplist;
ControllerUtility.postProcess(ctx);
logger.debug(
customLogger.debug(
'Native(Process-Transform):: Response from transformer::',
JSON.stringify(ctx.body),
);
Expand All @@ -93,7 +93,7 @@ export class DestinationController {

public static async destinationTransformAtRouter(ctx: Context) {
const startTime = new Date();
logger.debug(
customLogger.debug(
'Native(Router-Transform):: Requst to transformer::',
JSON.stringify(ctx.request.body),
);
Expand Down Expand Up @@ -140,7 +140,7 @@ export class DestinationController {
version: 'v0',
...metaTags,
});
logger.debug(
customLogger.debug(
'Native(Router-Transform):: Response from transformer::',
JSON.stringify(ctx.body),
);
Expand All @@ -154,7 +154,7 @@ export class DestinationController {
}

public static batchProcess(ctx: Context) {
logger.debug(
customLogger.debug(
'Native(Process-Transform-Batch):: Requst to transformer::',
JSON.stringify(ctx.request.body),
);
Expand Down Expand Up @@ -189,7 +189,7 @@ export class DestinationController {
ctx.body = [errResp];
}
ControllerUtility.postProcess(ctx);
logger.debug(
customLogger.debug(
'Native(Process-Transform-Batch):: Response from transformer::',
JSON.stringify(ctx.body),
);
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/regulation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context } from 'koa';
import logger from '@rudderstack/integrations-lib';
import customLogger from "@rudderstack/integrations-lib/build/structured-logger";
import { UserDeletionRequest, UserDeletionResponse } from '../types';
import { ServiceSelector } from '../helpers/serviceSelector';
import tags from '../v0/util/tags';
Expand All @@ -10,7 +10,7 @@ import { CatchErr } from '../util/types';

export class RegulationController {
public static async deleteUsers(ctx: Context) {
logger.debug(
customLogger.debug(
'Native(Process-Transform):: Requst to transformer::',
JSON.stringify(ctx.request.body),
);
Expand All @@ -23,7 +23,7 @@ export class RegulationController {
rudderDestInfo = destInfoHeader;
}
} catch (error) {
logger.error(`Error while getting rudderDestInfo header value: ${error}`);
customLogger.error(`Error while getting rudderDestInfo header value: ${error}`);
}

const userDeletionRequests = ctx.request.body as UserDeletionRequest[];
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/source.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Context } from 'koa';
import customLogger from "@rudderstack/integrations-lib/build/structured-logger";
import { MiscService } from '../services/misc';
import { ServiceSelector } from '../helpers/serviceSelector';
import { ControllerUtility } from './util';
import logger from '@rudderstack/integrations-lib';
import { SourcePostTransformationService } from '../services/source/postTransformation';

export class SourceController {
public static async sourceTransform(ctx: Context) {
logger.debug(
customLogger.debug(
'Native(Source-Transform):: Request to transformer::',
JSON.stringify(ctx.request.body),
);
Expand All @@ -34,7 +34,7 @@ export class SourceController {
ctx.body = [resp];
}
ControllerUtility.postProcess(ctx);
logger.debug(
customLogger.debug(
'Native(Source-Transform):: Response from transformer::',
JSON.stringify(ctx.body),
);
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import gracefulShutdown from 'http-graceful-shutdown';
import dotenv from 'dotenv';
import logger from '@rudderstack/integrations-lib';
import customLogger from "@rudderstack/integrations-lib/build/structured-logger";
import cluster from './util/cluster';
import { metricsRouter } from './routes/metricsRouter';
import { addStatMiddleware, addRequestSizeMiddleware, initPyroscope } from './middleware';
Expand Down Expand Up @@ -32,13 +32,13 @@ app.use(
addRequestSizeMiddleware(app);
addSwaggerRoutes(app);

logger.info('Using new routes');
customLogger.info('Using new routes');
applicationRoutes(app);

function finalFunction() {
RedisDB.disconnect();
logger.info('Redis client disconnected');
logger.error(`Process (pid: ${process.pid}) was gracefully shutdown`);
customLogger.info('Redis client disconnected');
customLogger.error(`Process (pid: ${process.pid}) was gracefully shutdown`);
logProcessInfo();
}

Expand All @@ -59,15 +59,15 @@ if (clusterEnabled) {
const server = app.listen(port);

process.on('SIGTERM', () => {
logger.error(`SIGTERM signal received`);
customLogger.error(`SIGTERM signal received`);
});

process.on('SIGINT', () => {
logger.error(`SIGINT signal received`);
customLogger.error(`SIGINT signal received`);
});

process.on('SIGSEGV', () => {
logger.error(`SIGSEGV - JavaScript memory error occurred`);
customLogger.error(`SIGSEGV - JavaScript memory error occurred`);
});

gracefulShutdown(server, {
Expand All @@ -77,7 +77,7 @@ if (clusterEnabled) {
finally: finalFunction,
});

logger.info(`App started. Listening on port: ${port}`);
customLogger.info(`App started. Listening on port: ${port}`);
}

export default app;
12 changes: 6 additions & 6 deletions src/services/destination/cdkV2Integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export class CDKV2DestinationService implements DestinationService {
tags.FEATURES.PROCESSOR,
);
metaTo.metadata = event.metadata;
const metadataWithSvcCtx = {
const metadataWithLoggingCtx = {
...requestMetadata,
serviceContext: MiscService.getLoggableData(metaTo.errorDetails),
loggerCtx: MiscService.getLoggableData(metaTo.errorDetails),
};
try {
const transformedPayloads:
Expand All @@ -78,7 +78,7 @@ export class CDKV2DestinationService implements DestinationService {
destinationType,
event,
tags.FEATURES.PROCESSOR,
metadataWithSvcCtx,
metadataWithLoggingCtx,
);

stats.increment('event_transform_success', {
Expand Down Expand Up @@ -132,17 +132,17 @@ export class CDKV2DestinationService implements DestinationService {
tags.FEATURES.ROUTER,
);
metaTo.metadata = destInputArray[0].metadata;
const metadataWithSvcCtx = {
const metadataWithLoggingCtx = {
...requestMetadata,
serviceContext: MiscService.getLoggableData(metaTo.errorDetails),
loggerCtx: MiscService.getLoggableData(metaTo.errorDetails),
};
try {
const doRouterTransformationResponse: RouterTransformationResponse[] =
await processCdkV2Workflow(
destinationType,
destInputArray,
tags.FEATURES.ROUTER,
metadataWithSvcCtx,
metadataWithLoggingCtx,
);
return DestinationPostTransformationService.handleRouterTransformSuccessEvents(
doRouterTransformationResponse,
Expand Down
Loading

0 comments on commit 30eb066

Please sign in to comment.