Skip to content

Commit

Permalink
partial sonar fix
Browse files Browse the repository at this point in the history
  • Loading branch information
furknyavuz committed Jun 27, 2022
1 parent 76aa81d commit 9f1b38d
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 44 deletions.
5 changes: 2 additions & 3 deletions app/consumer/payment-queue.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
};

Expand Down
13 changes: 7 additions & 6 deletions app/controller/payment.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion app/controller/receipt.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export class ReceiptController {
username,
product_id
);
};
}
}
2 changes: 2 additions & 0 deletions app/interface/payment-method.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions app/provider/coinbase-payment.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions app/provider/google-payment.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions app/provider/stripe-payment.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions app/repository/transaction-history.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -102,8 +102,8 @@ export class TransactionHistoryRepository {
findTransactionHistory = async (
_id: string
) => {
return await this.dataModel.findOne(
return this.dataModel.findOne(
{ _id }
)
}
);
};
}
2 changes: 1 addition & 1 deletion app/route/index.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export namespace Routes {
applicationName: 'PaymentServer',
} as MountAssets;

var routes: Array<Route> = [];
const routes: Array<Route> = [];

routes.push({ name: subRoutes.monitor, router: monitorRouter });
routes.push({ name: subRoutes.payment, router: paymentRouter });
Expand Down
2 changes: 1 addition & 1 deletion app/route/monitor.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
2 changes: 1 addition & 1 deletion app/route/subscription.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion app/wrapper/payment.wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions dependency-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ let indexOfDependedBy = -1;
console.log(
'<p align="center">\n' +
' <a href="https://opentemplatehub.com">\n' +
' <img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/ui/web-ui-logo.png" alt="Logo" width=200>\n' +
' <img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/server/payment-server-logo.png" alt="Logo" width=200>\n' +
' </a>\n' +
'</p>\n' +
'\n' +
'\n' +
'<h1 align="center">\n' +
'Open Template Hub - Company Profile UI Template v4\n' +
'Open Template Hub - Payment Server Template v4\n' +
' <br/>\n' +
'(outdated packages)\n' +
'</h1>\n' +
Expand Down
4 changes: 2 additions & 2 deletions docs/OUTDATED.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<p align="center">
<a href="https://opentemplatehub.com">
<img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/ui/web-ui-logo.png" alt="Logo" width=200>
<img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/server/payment-server-logo.png" alt="Logo" width=200>
</a>
</p>


<h1 align="center">
Open Template Hub - Company Profile UI Template v4
Open Template Hub - Payment Server Template v4
<br/>
(outdated packages)
</h1>
Expand Down

0 comments on commit 9f1b38d

Please sign in to comment.