From 28f7781fa2e1bee284a5d430e302c84c29115196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=81=C4=85giewka?= Date: Mon, 30 Dec 2024 09:36:04 +0100 Subject: [PATCH 1/2] Feature/eliminate body-parser (#4155) * Eliminate body-parser in favor of using @nestjs/platform-express * Update changelog --- CHANGELOG.md | 1 + apps/api/src/main.ts | 3 +-- package-lock.json | 2 -- package.json | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f476ee7..1a1111aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved support for automatic deletion of unused asset profiles when deleting activities - Improved the language localization for German (`de`) +- Eliminated `body-parser` in favor of using `@nestjs/platform-express` - Upgraded the _Stripe_ dependencies - Upgraded `angular` from version `18.2.8` to `19.0.5` - Upgraded `husky` from version `9.1.6` to `9.1.7` diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 9335e8d18..fdd6c1d99 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -7,7 +7,6 @@ import { import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import type { NestExpressApplication } from '@nestjs/platform-express'; -import { json } from 'body-parser'; import helmet from 'helmet'; import { AppModule } from './app/app.module'; @@ -48,7 +47,7 @@ async function bootstrap() { ); // Support 10mb csv/json files for importing activities - app.use(json({ limit: '10mb' })); + app.useBodyParser('json', { limit: '10mb' }); if (configService.get('ENABLE_FEATURE_SUBSCRIPTION') === 'true') { app.use( diff --git a/package-lock.json b/package-lock.json index b1a02ba76..d44d3be65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,6 @@ "@stripe/stripe-js": "5.4.0", "alphavantage": "2.2.0", "big.js": "6.2.2", - "body-parser": "1.20.2", "bootstrap": "4.6.0", "bull": "4.16.2", "cache-manager": "5.7.6", @@ -127,7 +126,6 @@ "@storybook/core-server": "8.4.7", "@trivago/prettier-plugin-sort-imports": "4.3.0", "@types/big.js": "6.2.2", - "@types/body-parser": "1.19.5", "@types/cache-manager": "4.0.6", "@types/color": "3.0.6", "@types/google-spreadsheet": "3.1.5", diff --git a/package.json b/package.json index 93d6f3c11..27b7e4ad0 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,6 @@ "@stripe/stripe-js": "5.4.0", "alphavantage": "2.2.0", "big.js": "6.2.2", - "body-parser": "1.20.2", "bootstrap": "4.6.0", "bull": "4.16.2", "cache-manager": "5.7.6", @@ -173,7 +172,6 @@ "@storybook/core-server": "8.4.7", "@trivago/prettier-plugin-sort-imports": "4.3.0", "@types/big.js": "6.2.2", - "@types/body-parser": "1.19.5", "@types/cache-manager": "4.0.6", "@types/color": "3.0.6", "@types/google-spreadsheet": "3.1.5", From ff7caf9c5c6368725891adc6d7363c20a0235f7e Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:21:11 +0100 Subject: [PATCH 2/2] Feature/migrate coupon redemption prompt dialog (#4150) * Migrate coupon redemption prompt dialog * Update changelog --- CHANGELOG.md | 1 + .../user-account-membership.component.ts | 86 ++++++++++--------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a1111aa3..f0cfcbadc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved support for automatic deletion of unused asset profiles when deleting activities +- Migrated the coupon redemption to the notification service for prompt dialogs - Improved the language localization for German (`de`) - Eliminated `body-parser` in favor of using `@nestjs/platform-express` - Upgraded the _Stripe_ dependencies diff --git a/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts b/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts index d6f85f053..6139d173e 100644 --- a/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts +++ b/apps/client/src/app/components/user-account-membership/user-account-membership.component.ts @@ -164,50 +164,54 @@ export class UserAccountMembershipComponent implements OnDestroy { } public onRedeemCoupon() { - let couponCode = prompt($localize`Please enter your coupon code:`); - couponCode = couponCode?.trim(); - - if (couponCode) { - this.dataService - .redeemCoupon(couponCode) - .pipe( - catchError(() => { - this.snackBar.open( - '😞 ' + $localize`Could not redeem coupon code`, - undefined, - { - duration: ms('3 seconds') - } - ); - - return EMPTY; - }), - takeUntil(this.unsubscribeSubject) - ) - .subscribe(() => { - this.snackBarRef = this.snackBar.open( - '✅ ' + $localize`Coupon code has been redeemed`, - $localize`Reload`, - { - duration: 3000 - } - ); - - this.snackBarRef - .afterDismissed() - .pipe(takeUntil(this.unsubscribeSubject)) + this.notificationService.prompt({ + confirmFn: (value) => { + const couponCode = value?.trim(); + + if (couponCode) { + this.dataService + .redeemCoupon(couponCode) + .pipe( + catchError(() => { + this.snackBar.open( + '😞 ' + $localize`Could not redeem coupon code`, + undefined, + { + duration: ms('3 seconds') + } + ); + + return EMPTY; + }), + takeUntil(this.unsubscribeSubject) + ) .subscribe(() => { - window.location.reload(); - }); + this.snackBarRef = this.snackBar.open( + '✅ ' + $localize`Coupon code has been redeemed`, + $localize`Reload`, + { + duration: 3000 + } + ); - this.snackBarRef - .onAction() - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(() => { - window.location.reload(); + this.snackBarRef + .afterDismissed() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(() => { + window.location.reload(); + }); + + this.snackBarRef + .onAction() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(() => { + window.location.reload(); + }); }); - }); - } + } + }, + title: $localize`Please enter your coupon code.` + }); } public ngOnDestroy() {