Merge pull request 'Fix app crashes' (#4) from feat-3-fix-crashes into main

Reviewed-on: #4
pull/5/head
Inga 🏳‍🌈 10 months ago
commit b356ec8022
  1. 1
      .eslintrc.js
  2. 2
      src/main.ts
  3. 21
      src/transaction/transaction.controller.ts

@ -16,6 +16,7 @@ module.exports = {
}, },
ignorePatterns: ['.eslintrc.js'], ignorePatterns: ['.eslintrc.js'],
rules: { rules: {
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',

@ -6,4 +6,4 @@ async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule); const app = await NestFactory.create<NestExpressApplication>(AppModule);
await app.listen(3000); await app.listen(3000);
} }
bootstrap(); void bootstrap();

@ -117,17 +117,22 @@ export class TransactionController {
try { try {
this.exchangeRateService.convertCurrency(exhangeRateInput).subscribe({ this.exchangeRateService.convertCurrency(exhangeRateInput).subscribe({
next: async (exchangeRateResponse) => { next: (exchangeRateResponse) =>
commissionAmount
.then((commission) =>
this.transactionService.insertOne({ this.transactionService.insertOne({
date: transactionInput.date, date: transactionInput.date,
amount: parseInt(transactionInput.amount), amount: parseInt(transactionInput.amount),
currency: transactionInput.currency, currency: transactionInput.currency,
client_id: transactionInput.client_id, client_id: transactionInput.client_id,
commission: await commissionAmount, commission,
base_currency: Currency.EUR, base_currency: Currency.EUR,
base_amount: parseInt(transactionInput.amount) * exchangeRateResponse[transactionInput.currency], base_amount:
}); parseInt(transactionInput.amount) *
}, exchangeRateResponse[transactionInput.currency],
}),
)
.catch((error) => console.log(error)),
error: (error) => { error: (error) => {
console.log(error); console.log(error);
}, },
@ -145,7 +150,8 @@ export class TransactionController {
transactionInput, transactionInput,
); );
try { try {
this.transactionService.insertOne({ this.transactionService
.insertOne({
date: transactionInput.date, date: transactionInput.date,
amount: parseInt(transactionInput.amount), amount: parseInt(transactionInput.amount),
currency: transactionInput.currency, currency: transactionInput.currency,
@ -153,7 +159,8 @@ export class TransactionController {
commission: commissionAmount, commission: commissionAmount,
base_currency: Currency.EUR, base_currency: Currency.EUR,
base_amount: parseInt(transactionInput.amount), base_amount: parseInt(transactionInput.amount),
}); })
.catch((error) => console.log(error));
} catch (error) { } catch (error) {
console.log(error); console.log(error);
throw error; throw error;

Loading…
Cancel
Save