Fix app crashes #4

Merged
inga-lovinde merged 2 commits from feat-3-fix-crashes into main 10 months ago
  1. 1
      .eslintrc.js
  2. 2
      src/main.ts
  3. 47
      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) =>
this.transactionService.insertOne({ commissionAmount
date: transactionInput.date, .then((commission) =>
amount: parseInt(transactionInput.amount), this.transactionService.insertOne({
currency: transactionInput.currency, date: transactionInput.date,
client_id: transactionInput.client_id, amount: parseInt(transactionInput.amount),
commission: await commissionAmount, currency: transactionInput.currency,
base_currency: Currency.EUR, client_id: transactionInput.client_id,
base_amount: parseInt(transactionInput.amount) * exchangeRateResponse[transactionInput.currency], commission,
}); base_currency: Currency.EUR,
}, base_amount:
parseInt(transactionInput.amount) *
exchangeRateResponse[transactionInput.currency],
}),
)
.catch((error) => console.log(error)),
error: (error) => { error: (error) => {
console.log(error); console.log(error);
}, },
@ -145,15 +150,17 @@ export class TransactionController {
transactionInput, transactionInput,
); );
try { try {
this.transactionService.insertOne({ this.transactionService
date: transactionInput.date, .insertOne({
amount: parseInt(transactionInput.amount), date: transactionInput.date,
currency: transactionInput.currency, amount: parseInt(transactionInput.amount),
client_id: transactionInput.client_id, currency: transactionInput.currency,
commission: commissionAmount, client_id: transactionInput.client_id,
base_currency: Currency.EUR, commission: commissionAmount,
base_amount: parseInt(transactionInput.amount), base_currency: Currency.EUR,
}); 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