Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
472c9a8
BAN-113 chore: add socket.io-client
backtobackend Oct 2, 2025
db76b10
BAN-113 feat: websocket refactor in proccess
backtobackend Oct 3, 2025
982a0e4
jenkinsfile
backtobackend Oct 14, 2025
c17f530
js
backtobackend Oct 14, 2025
f172066
try
backtobackend Oct 16, 2025
66f391f
BAN-113
backtobackend Oct 16, 2025
56e39e1
BAN-113: jenkins
backtobackend Oct 16, 2025
8078370
BAN-113 deployment
backtobackend Oct 16, 2025
acc992d
...
backtobackend Oct 16, 2025
23e6714
BAN-113
backtobackend Oct 16, 2025
a69524d
users deployment
backtobackend Oct 16, 2025
a1dfc07
posts deployment
backtobackend Oct 16, 2025
aaeb0ec
files deploy
backtobackend Oct 17, 2025
d41d5b0
business deployment
backtobackend Oct 17, 2025
e50ffff
Deployment
backtobackend Oct 17, 2025
a671f62
mailer deploy
backtobackend Oct 17, 2025
a228f20
gate fix config
backtobackend Oct 17, 2025
10dde1a
gate prod
backtobackend Oct 17, 2025
0b60125
env gate change
backtobackend Oct 17, 2025
761799d
logs
backtobackend Oct 17, 2025
11909c8
ENV PORT GATE
backtobackend Oct 17, 2025
da6b125
remove api/v1 from gate configuration
backtobackend Oct 18, 2025
2207266
gate deployment
backtobackend Oct 18, 2025
40769e9
ddd
backtobackend Oct 18, 2025
5d55be9
fff
backtobackend Oct 18, 2025
fd4511d
....
backtobackend Oct 18, 2025
49c7d39
autoLoadEntities true
backtobackend Oct 18, 2025
266a081
business typeorm
backtobackend Oct 18, 2025
eadae20
Merge branch 'main' into refactor/BAN-113-Notifications-Gate
backtobackend226 Oct 17, 2025
ba4720e
business typeorm
backtobackend Oct 18, 2025
bb10776
BAN--113 fix: remove cors
backtobackend Oct 22, 2025
82c6cc6
BAN-113 cors *
backtobackend Oct 22, 2025
8aeb780
return cors
backtobackend Oct 23, 2025
e520256
+ * headers
backtobackend Oct 23, 2025
5423827
return link when subscribe
backtobackend Oct 24, 2025
5af9a5f
add paypal cors
backtobackend Oct 24, 2025
7f2e901
BAN-113 redirect to the front at the end of subscription process
backtobackend Oct 25, 2025
434c316
BAN-113 log
backtobackend Oct 25, 2025
aa62862
BAN-113 comment notif
backtobackend Oct 25, 2025
e4414d5
BAN-113 google redirect
backtobackend Oct 27, 2025
6e2e0a8
BAN-113 user cant have more than 2 not expired subscriptions simultan…
backtobackend Oct 27, 2025
9727632
BAN-113 business redirect gate
backtobackend Oct 27, 2025
2a5f320
BAN-113 feat: cancel subscription
backtobackend Oct 28, 2025
516c0d2
BAN-113 feat: paypal does not spam webhooks
backtobackend Oct 28, 2025
e86f587
BAN logs
backtobackend Nov 6, 2025
7c82d97
BAN-113
backtobackend Nov 6, 2025
6769141
BAN-113 feat: add successUrl and cancelUrl
backtobackend Nov 6, 2025
21afc38
/...
backtobackend Nov 6, 2025
f65a36d
BAN-113 feat: add expiresAt to paymentresponsedto
backtobackend Nov 7, 2025
7253032
ffff
backtobackend Jan 20, 2026
bcf64f8
add injectable()
backtobackend Jan 22, 2026
9402918
feat: //
backtobackend Jan 22, 2026
083e856
/try///
backtobackend Jan 22, 2026
8bca5d8
//try////
backtobackend Jan 22, 2026
3d8d6c1
try
backtobackend Jan 22, 2026
e016120
init
backtobackend Jan 22, 2026
7782edf
....
backtobackend Jan 22, 2026
67a6b94
fix: node_env
backtobackend Jan 22, 2026
b735278
dddd
backtobackend Jan 22, 2026
5ac7d73
ddd
backtobackend Jan 22, 2026
7cd02f2
feat: logs notif
backtobackend Jan 23, 2026
6fe1a11
log
backtobackend Jan 23, 2026
1d4c318
add subsription to payemntDto
backtobackend Jan 25, 2026
48f86db
fff
backtobackend Jan 25, 2026
c83c79f
feat: save notif
backtobackend Jan 26, 2026
3e172f8
fff
backtobackend Jan 26, 2026
17b0679
ее
backtobackend Jan 26, 2026
c46ee05
fixed read notif
backtobackend Jan 26, 2026
f7374b6
feat: notif works
backtobackend Jan 30, 2026
f69245a
3000 port websockets
backtobackend Jan 30, 2026
d6b23c6
fff
backtobackend Jan 30, 2026
fa8e33d
hgggg
backtobackend Jan 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions apps/business/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pipeline {
agent any
environment {
ENV_TYPE = "production"
PORT = 3986
PORT = 4161
NAMESPACE = "yogram-ru"
REGISTRY_HOSTNAME = "idogmat"
PROJECT = "business"
PROJECT = "business-yogram"
SERVICE="business"
REGISTRY = "registry.hub.docker.com"
DEPLOYMENT_NAME = "business-deployment"
DEPLOYMENT_NAME = "business-yogram-deployment"
IMAGE_NAME = "${env.BUILD_ID}_${env.ENV_TYPE}_${env.GIT_COMMIT}"
DOCKER_BUILD_NAME = "${env.REGISTRY_HOSTNAME}/${env.PROJECT}:${env.IMAGE_NAME}"
}
Expand All @@ -20,31 +20,31 @@ pipeline {
checkout scm
}
}
stage('Unit tests') {
steps {
script {
sh '''
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use --lts
yarn install
yarn test
'''
}
}
}
stage('e2e tests') {
steps {
script {
sh '''
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use --lts
yarn test:e2e
'''
}
}
}
// stage('Unit tests') {
// steps {
// script {
// sh '''
// export NVM_DIR="$HOME/.nvm"
// [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
// nvm use --lts
// yarn install
// yarn test
// '''
// }
// }
// }
// stage('e2e tests') {
// steps {
// script {
// sh '''
// export NVM_DIR="$HOME/.nvm"
// [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
// nvm use --lts
// yarn test:e2e
// '''
// }
// }
// }
stage('Build docker image') {
steps {
echo "Build image started..."
Expand Down
65 changes: 32 additions & 33 deletions apps/business/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,64 @@ spec:
image: REGISTRY_HOSTNAME/PROJECT:TAG_VERSION
ports:
- containerPort: PORT_CONTAINER

env:
- name: POSTGRES_TYPE
valueFrom:
secretKeyRef:
name: business-production-config-secret
key: POSTGRES_TYPE
- name: BUSINESS_SERVICE_URL
valueFrom:
secretKeyRef:
name: business-production-config-secret
key: BUSINESS_SERVICE_URL
- name: POSTGRES_URL_SLAVE
valueFrom:
secretKeyRef:
name: business-production-config-secret
key: POSTGRES_URL_SLAVE
- name: PAYPAL_CLIENT_ID
valueFrom:
secretKeyRef:
name: business-production-config-secret
key: PAYPAL_CLIENT_ID
- name: PAYPAL_SECRET
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: PAYPAL_SECRET
- name: USERS_SERVICE_URL
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: USERS_SERVICE_URL
- name: REDIS_USER
valueFrom:
secretKeyRef:
name: business-production-config-secret
key: REDIS_USER
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: REDIS_PASSWORD
- name: REDIS_HOST
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: REDIS_HOST
- name: REDIS_PORT
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: REDIS_PORT
- name: TIME_PERIOD
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: TIME_PERIOD
- name: REDIS_USER
valueFrom:
secretKeyRef:
name: business-yogram-production-config-secret
key: REDIS_USER
- name: BUSINESS_SERVICE_URL
valueFrom:
secretKeyRef:
name: business-yogram-production-config-secret
key: BUSINESS_SERVICE_URL
- name: POSTGRES_TYPE
valueFrom:
secretKeyRef:
name: business-yogram-production-config-secret
key: POSTGRES_TYPE
- name: POSTGRES_URL
valueFrom:
secretKeyRef:
name: business-production-config-secret
name: business-yogram-production-config-secret
key: POSTGRES_URL
- name: PROFILE_SETTINGS_PAGE
valueFrom:
secretKeyRef:
name: business-yogram-production-config-secret
key: PROFILE_SETTINGS_PAGE
- name: PAYPAL_CLIENT_ID
valueFrom:
secretKeyRef:
name: business-yogram-production-config-secret
key: PAYPAL_CLIENT_ID
26 changes: 25 additions & 1 deletion apps/business/src/api/business.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Param,
Patch,
Post,
Res,
Sse,
} from '@nestjs/common';
import {
Expand All @@ -38,13 +39,17 @@ import {
import { NotificationResponseDto } from 'apps/libs/Business/dto/response/response-notification.dto';
import { ReadNotificationCommand } from '../application/command/read-notification.command';
import { ReadNotificationDto } from '../../../../apps/libs/Business/dto/input/read-notification.dto';
import { Response } from 'express';
import { ConfigService } from '@nestjs/config';
import { CancelSubscriptionCommand } from '../application/command/cancel-subscription.handler';

@Controller()
export class BusinessController {
private eventEmitter: EventEmitter2;
constructor(
private readonly commandBus: CommandBus,
private readonly queryBus: QueryBus,
private readonly configService: ConfigService,
) {
this.eventEmitter = new EventEmitter2();
}
Expand All @@ -57,8 +62,20 @@ export class BusinessController {
@Post('business/paypal-proccess')
async paypalProcess(
@Body('subscriptionId') subscriptionId: string,
@Res() res: Response,
): Promise<void> {
await this.commandBus.execute(new SaveSubscriptionCommand(subscriptionId));
console.log(
'🚀 ~ BusinessController ~ paypalProcess ~ subscriptionId:',
subscriptionId,
);
const subscription = await this.commandBus.execute(
new SaveSubscriptionCommand(subscriptionId),
);
res.status(200).json(subscription);
// let page = this.configService.get<string>('PROFILE_SETTINGS_PAGE');
// page = page.replace('replace', subscription.userId);
// console.log('🚀 ~ BusinessController ~ paypalProcess ~ page:', page);
// res.redirect(301, 'https://www.google.com/');
}

@HttpCode(200)
Expand Down Expand Up @@ -113,6 +130,12 @@ export class BusinessController {
return await this.commandBus.execute(new ActivateSubscriptionCommand(id));
}

@Patch('business/subscriptions/:id/cancel')
async cancelSubscription(@Param('id') id: string): Promise<void> {
console.log('🚀 ~ BusinessController ~ cancelSubscription ~ id:', id);
return await this.commandBus.execute(new CancelSubscriptionCommand(id));
}

@Get('business/subscriptions/get/:id')
async getCurrentSubscriptions(
@Param('id') userId: string,
Expand All @@ -137,6 +160,7 @@ export class BusinessController {
async getUserNotifications(
@Param('id') id: string,
): Promise<NotificationResponseDto[]> {
console.log('🚀 ~ BusinessController ~ getUserNotifications ~ id:', id);
return await this.queryBus.execute(new GetUserNotificationsQuery(id));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { BusinessCommandService } from '../../business-command.service';

export class CancelSubscriptionCommand {
constructor(public readonly id: string) {}
}

@CommandHandler(CancelSubscriptionCommand)
export class CancelSubscriptionHandler
implements ICommandHandler<CancelSubscriptionCommand>
{
constructor(
private readonly businessCommandService: BusinessCommandService,
) {}

async execute({ id }: CancelSubscriptionCommand): Promise<any> {
return await this.businessCommandService.cancelSubscription(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export class ReadNotificationHandler
) {}

async execute({ notificationId }: ReadNotificationCommand): Promise<any> {
return await this.businessCommandService.updateNotification(notificationId);
// return await this.businessCommandService.updateNotification(notificationId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BusinessCommandService } from '../../business-command.service';
import { WebsocketEvents } from '../../constants/websocket.event.enum';
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { v4 } from 'uuid';
import { NotificationsService } from '../../notifications.service';
export class SaveSubscriptionCommand {
constructor(public readonly id: string) {}
}
Expand All @@ -16,7 +17,7 @@ export class SaveSubscriptionHandler
{
constructor(
private readonly businessCommandService: BusinessCommandService,
private readonly notificationGateway: NotificationsGateway,
private readonly notificationsService: NotificationsService,
) {}

async execute({ id }: SaveSubscriptionCommand): Promise<Subscription> {
Expand All @@ -29,15 +30,17 @@ export class SaveSubscriptionHandler
userId: subscription.userId,
expiresAt: new Date(subscription.expiresAt).getTime(),
createdAt: new Date(subscription.createdAt).getTime(),
delivered: false,
};

const key = getNotificationKey(subscription, notification);
await this.notificationGateway.saveNotification(
// todo uncomment notif
await this.notificationsService.saveNotification(
key,
notification,
2629746000,
);
await this.notificationGateway.send(
await this.notificationsService.send(
notification,
WebsocketEvents.SubscriptionActive,
30000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { WebsocketEvents } from '../../constants/websocket.event.enum';
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { v4 } from 'uuid';
import { Subscription } from '../../infrastructure/entity/subscription.entity';
import { NotificationsService } from '../../notifications.service';

export class SubscriptionUpdatedCommand {
constructor(public readonly subscriptionId: string) {}
Expand All @@ -17,7 +18,7 @@ export class SubscriptionUpdatedHandler
{
constructor(
private readonly businessCommandService: BusinessCommandService,
private readonly notificationGateway: NotificationsGateway,
private readonly notificationsService: NotificationsService,
) {}
async execute({
subscriptionId,
Expand All @@ -34,14 +35,15 @@ export class SubscriptionUpdatedHandler
userId: subscription.userId,
expiresAt: new Date(subscription.expiresAt).getTime(),
createdAt: new Date(subscription.createdAt).getTime(),
delivered: false,
};
const key = getNotificationKey(subscription, notification);
await this.notificationGateway.saveNotification(
await this.notificationsService.saveNotification(
key,
notification,
2629746000,
);
await this.notificationGateway.send(
await this.notificationsService.send(
notification,
WebsocketEvents.SubscriptionActive,
30000,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { INotification } from '../../../../../apps/libs/common/notifications/interfaces/notification.interface';
import { NotificationsGateway } from '../../../../../apps/libs/common/notifications/notifications.gateway';
import { IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { NotificationsService } from '../../notifications.service';

export class GetUserNotificationsQuery {
constructor(public readonly userId: string) {}
Expand All @@ -10,11 +10,11 @@ export class GetUserNotificationsQuery {
export class GetUserNotificationsHandler
implements IQueryHandler<GetUserNotificationsQuery>
{
constructor(private readonly notificationGateway: NotificationsGateway) {}
constructor(private readonly notificationsService: NotificationsService) {}

async execute({
userId,
}: GetUserNotificationsQuery): Promise<INotification[]> {
return await this.notificationGateway.getUserNotifications(userId);
return await this.notificationsService.getUserNotifications(userId);
}
}
Loading