From 9f1b38d4058cc8017b191d3d687dcccaed695575 Mon Sep 17 00:00:00 2001 From: Furkan Yavuz Date: Mon, 27 Jun 2022 19:29:03 +0300 Subject: [PATCH] partial sonar fix --- app/consumer/payment-queue.consumer.ts | 5 ++--- app/controller/payment.controller.ts | 13 +++++++------ app/controller/receipt.controller.ts | 2 +- app/interface/payment-method.interface.ts | 2 ++ app/provider/coinbase-payment.provider.ts | 7 ------- app/provider/google-payment.provider.ts | 7 ------- app/provider/stripe-payment.provider.ts | 7 ------- app/repository/transaction-history.repository.ts | 10 +++++----- app/route/index.route.ts | 2 +- app/route/monitor.route.ts | 2 +- app/route/subscription.route.ts | 2 +- app/wrapper/payment.wrapper.ts | 2 +- dependency-checker.ts | 4 ++-- docs/OUTDATED.md | 4 ++-- 14 files changed, 25 insertions(+), 44 deletions(-) diff --git a/app/consumer/payment-queue.consumer.ts b/app/consumer/payment-queue.consumer.ts index 5b947e2..8993eec 100644 --- a/app/consumer/payment-queue.consumer.ts +++ b/app/consumer/payment-queue.consumer.ts @@ -5,11 +5,10 @@ import { } from '@open-template-hub/common'; export class PaymentQueueConsumer implements QueueConsumer { + private channel: any; private ctxArgs: ContextArgs = {} as ContextArgs; - constructor() {} - init = (channel: string, ctxArgs: ContextArgs) => { this.channel = channel; this.ctxArgs = ctxArgs; @@ -27,7 +26,7 @@ export class PaymentQueueConsumer implements QueueConsumer { let requeue = false; if (message.example) { - var exampleHook = async () => { + const exampleHook = async () => { console.log('Payment server example'); }; diff --git a/app/controller/payment.controller.ts b/app/controller/payment.controller.ts index d75b8cd..6db7919 100644 --- a/app/controller/payment.controller.ts +++ b/app/controller/payment.controller.ts @@ -20,10 +20,11 @@ import { TransactionHistoryRepository } from '../repository/transaction-history. import { PaymentWrapper } from '../wrapper/payment.wrapper'; export class PaymentController { - constructor( - private environment = new Environment() - ) { - // intentionally blank + + environment: Environment; + + constructor() { + this.environment = new Environment(); } /** @@ -292,11 +293,11 @@ export class PaymentController { ); if ( status && ReceiptStatus.SUCCESS === status ) { - await this.sendPaymentSuccessNotificationToQueue(message_queue_provider, { + await this.sendPaymentSuccessNotificationToQueue( message_queue_provider, { timestamp: new Date().getTime(), username: updated_transaction_history.username, message: 'Product paid successfully' - }); + } ); } } catch ( error ) { diff --git a/app/controller/receipt.controller.ts b/app/controller/receipt.controller.ts index 60a827d..28ea02c 100644 --- a/app/controller/receipt.controller.ts +++ b/app/controller/receipt.controller.ts @@ -23,5 +23,5 @@ export class ReceiptController { username, product_id ); - }; + } } diff --git a/app/interface/payment-method.interface.ts b/app/interface/payment-method.interface.ts index 154503d..b1dd3a7 100644 --- a/app/interface/payment-method.interface.ts +++ b/app/interface/payment-method.interface.ts @@ -6,12 +6,14 @@ import { PaymentConfig } from './payment-config.interface'; import { Product } from './product.interface'; export interface PaymentMethod { + /** * initializes payment method * @param dbConn db connection * @param paymentConfig payment config * @param product product * @param quantity quantity + * @param transaction_id transaction_id */ init( dbConn: any, diff --git a/app/provider/coinbase-payment.provider.ts b/app/provider/coinbase-payment.provider.ts index cf72aa5..173e26f 100644 --- a/app/provider/coinbase-payment.provider.ts +++ b/app/provider/coinbase-payment.provider.ts @@ -14,13 +14,6 @@ import { PaymentMethodEnum } from '../wrapper/payment.wrapper'; export class CoinbasePayment implements PaymentMethod { private readonly SUCCESS_STATUS = 'CONFIRMED'; - /** - * initializes coinbase payment provider - * @param dbConn db connection - * @param paymentConfig payment config - * @param product product - * @param quantity quantity - */ init = async ( dbConn: any, paymentConfig: PaymentConfig, diff --git a/app/provider/google-payment.provider.ts b/app/provider/google-payment.provider.ts index 52da1bc..c43ce03 100644 --- a/app/provider/google-payment.provider.ts +++ b/app/provider/google-payment.provider.ts @@ -9,13 +9,6 @@ import { Product } from '../interface/product.interface'; export class GooglePayment implements PaymentMethod { private readonly SUCCESS_STATUS = 'succeeded'; - /** - * initializes google payment provider - * @param dbConn db connection - * @param paymentConfig payment config - * @param product product - * @param quantity quantity - */ init = async ( dbConn: any, paymentConfig: PaymentConfig, diff --git a/app/provider/stripe-payment.provider.ts b/app/provider/stripe-payment.provider.ts index d1e5580..1459708 100644 --- a/app/provider/stripe-payment.provider.ts +++ b/app/provider/stripe-payment.provider.ts @@ -15,13 +15,6 @@ import { PaymentMethodEnum } from '../wrapper/payment.wrapper'; export class StripePayment implements PaymentMethod { private readonly SUCCESS_STATUS = 'succeeded'; - /** - * initializes stripe payment provider - * @param dbConn db connection - * @param paymentConfig payment config - * @param product product - * @param quantity quantity - */ init = async ( dbConn: any, paymentConfig: PaymentConfig, diff --git a/app/repository/transaction-history.repository.ts b/app/repository/transaction-history.repository.ts index 8d7867b..ca221fb 100644 --- a/app/repository/transaction-history.repository.ts +++ b/app/repository/transaction-history.repository.ts @@ -64,12 +64,12 @@ export class TransactionHistoryRepository { return await this.dataModel.findOneAndUpdate( { _id: id }, { external_transaction_id, payload: { transaction_history } } - ) + ); } catch ( error ) { console.error( '> updateTransactionHistoryWithId error: ', error ); throw error; } - } + }; /** * updates transaction history with external transaction id @@ -102,8 +102,8 @@ export class TransactionHistoryRepository { findTransactionHistory = async ( _id: string ) => { - return await this.dataModel.findOne( + return this.dataModel.findOne( { _id } - ) - } + ); + }; } diff --git a/app/route/index.route.ts b/app/route/index.route.ts index 96cd3e9..8cf7b39 100644 --- a/app/route/index.route.ts +++ b/app/route/index.route.ts @@ -44,7 +44,7 @@ export namespace Routes { applicationName: 'PaymentServer', } as MountAssets; - var routes: Array = []; + const routes: Array = []; routes.push({ name: subRoutes.monitor, router: monitorRouter }); routes.push({ name: subRoutes.payment, router: paymentRouter }); diff --git a/app/route/monitor.route.ts b/app/route/monitor.route.ts index 593aaf4..e897899 100644 --- a/app/route/monitor.route.ts +++ b/app/route/monitor.route.ts @@ -9,7 +9,7 @@ const subRoutes = { export const router = Router(); -router.get(subRoutes.alive, async (req: Request, res: Response) => { +router.get(subRoutes.alive, async (_req: Request, res: Response) => { // checks is alive res.status(ResponseCode.OK).send(); }); diff --git a/app/route/subscription.route.ts b/app/route/subscription.route.ts index 1187aae..408f441 100644 --- a/app/route/subscription.route.ts +++ b/app/route/subscription.route.ts @@ -55,7 +55,7 @@ router.get( router.get( subRoutes.me, authorizedBy([UserRole.ADMIN, UserRole.DEFAULT]), - async (req: Request, res: Response) => { + async (_req: Request, res: Response) => { // Get subscription with username const context = res.locals.ctx; diff --git a/app/wrapper/payment.wrapper.ts b/app/wrapper/payment.wrapper.ts index fe90acb..1246e12 100644 --- a/app/wrapper/payment.wrapper.ts +++ b/app/wrapper/payment.wrapper.ts @@ -108,7 +108,7 @@ export class PaymentWrapper implements PaymentMethod { if ( this.paymentMethod === undefined ) { return ''; } - return await this.paymentMethod.receiptStatusUpdate( + return this.paymentMethod.receiptStatusUpdate( dbConn, paymentConfig, external_transaction_id, diff --git a/dependency-checker.ts b/dependency-checker.ts index fa619d8..54417de 100644 --- a/dependency-checker.ts +++ b/dependency-checker.ts @@ -10,13 +10,13 @@ let indexOfDependedBy = -1; console.log( '

\n' + ' \n' + - ' Logo\n' + + ' Logo\n' + ' \n' + '

\n' + '\n' + '\n' + '

\n' + - 'Open Template Hub - Company Profile UI Template v4\n' + + 'Open Template Hub - Payment Server Template v4\n' + '
\n' + '(outdated packages)\n' + '

\n' + diff --git a/docs/OUTDATED.md b/docs/OUTDATED.md index 921a435..7dbe275 100644 --- a/docs/OUTDATED.md +++ b/docs/OUTDATED.md @@ -1,12 +1,12 @@

- Logo + Logo

-Open Template Hub - Company Profile UI Template v4 +Open Template Hub - Payment Server Template v4
(outdated packages)