From 781884a4cdf5aa780a1778fdc01e1ff6922b151c Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Thu, 21 Dec 2023 17:34:56 +0530 Subject: [PATCH 1/6] refactor:fetch user profile api Signed-off-by: pranalidhanavade --- apps/api-gateway/src/user/user.controller.ts | 7 +++- apps/api-gateway/src/user/user.service.ts | 5 ++- apps/user/interfaces/user.interface.ts | 39 +++++++++++++++----- apps/user/repositories/user.repository.ts | 6 +-- apps/user/src/user.controller.ts | 4 +- apps/user/src/user.service.ts | 4 +- 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/apps/api-gateway/src/user/user.controller.ts b/apps/api-gateway/src/user/user.controller.ts index 9cf602c33..2c1b696bc 100644 --- a/apps/api-gateway/src/user/user.controller.ts +++ b/apps/api-gateway/src/user/user.controller.ts @@ -15,6 +15,7 @@ import { import { UserService } from './user.service'; import { ApiBearerAuth, + ApiExcludeEndpoint, ApiForbiddenResponse, ApiOperation, ApiParam, @@ -69,6 +70,7 @@ export class UserController { * @returns Users list of organization */ @Get('/public-profiles') + @ApiExcludeEndpoint() @ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto }) @ApiOperation({ summary: 'Get users list', description: 'Get users list.' }) @ApiQuery({ @@ -102,6 +104,7 @@ export class UserController { } @Get('public-profiles/:username') + @ApiExcludeEndpoint() @ApiOperation({ summary: 'Fetch user details', description: 'Fetch user details' @@ -130,13 +133,13 @@ export class UserController { }) @UseGuards(AuthGuard('jwt')) @ApiBearerAuth() - async getProfile(@User() reqUser: user, @Res() res: Response): Promise { + async getProfile(@User() reqUser: user, @Res() res: Response): Promise { const userData = await this.userService.getProfile(reqUser.id); const finalResponse: IResponseType = { statusCode: HttpStatus.OK, message: ResponseMessages.user.success.fetchProfile, - data: userData.response + data: userData }; return res.status(HttpStatus.OK).json(finalResponse); diff --git a/apps/api-gateway/src/user/user.service.ts b/apps/api-gateway/src/user/user.service.ts index e6e98658e..266c96372 100644 --- a/apps/api-gateway/src/user/user.service.ts +++ b/apps/api-gateway/src/user/user.service.ts @@ -9,6 +9,7 @@ import { UpdateUserProfileDto } from './dto/update-user-profile.dto'; import { AddPasskeyDetails } from './dto/add-user.dto'; import { UpdatePlatformSettingsDto } from './dto/update-platform-settings.dto'; import { CreateUserCertificateDto } from './dto/share-certificate.dto'; +import { UsersProfile } from 'apps/user/interfaces/user.interface'; @Injectable() export class UserService extends BaseService { @@ -16,9 +17,9 @@ export class UserService extends BaseService { super('User Service'); } - async getProfile(id: string): Promise<{ response: object }> { + async getProfile(id: string): Promise { const payload = { id }; - return this.sendNats(this.serviceProxy, 'get-user-profile', payload); + return this.sendNatsMessage(this.serviceProxy, 'get-user-profile', payload); } async getPublicProfile(username: string): Promise<{ response: object }> { diff --git a/apps/user/interfaces/user.interface.ts b/apps/user/interfaces/user.interface.ts index 5ce80c6eb..c0446e58f 100644 --- a/apps/user/interfaces/user.interface.ts +++ b/apps/user/interfaces/user.interface.ts @@ -23,14 +23,35 @@ export interface Organisation { } export interface UsersProfile { - id?: string; - username?: string; - email?: string; - firstName?: string; - lastName?: string; - supabaseUserId?: string; - userOrgRoles?: object; - } + id?: string; + username?: string; + email?: string; + firstName?: string; + lastName?: string; + supabaseUserId?: string; + userOrgRoles?: UserOrgRole[]; +} + +interface UserOrgRole { + id: string; + userId: string; + orgRoleId: string; + orgId: string; + orgRole: { + id: string; + name: string; + description: string; + }; + organisation: { + id: string; + name: string; + description: string; + orgSlug: string; + logoUrl: string; + website: string; + publicProfile: boolean; + }; +} export interface OrgInvitations { id: string; @@ -48,7 +69,7 @@ export interface UsersProfile { username?: string; } - export interface userInfo { + export interface UserInfo { email: string; password: string; firstName: string; diff --git a/apps/user/repositories/user.repository.ts b/apps/user/repositories/user.repository.ts index 513c534df..ce4d23eca 100644 --- a/apps/user/repositories/user.repository.ts +++ b/apps/user/repositories/user.repository.ts @@ -9,7 +9,7 @@ import { UserCredentials, UserEmailVerificationDto, UsersProfile, - userInfo + UserInfo } from '../interfaces/user.interface'; import { InternalServerErrorException } from '@nestjs/common'; @@ -254,7 +254,7 @@ export class UserRepository { }); } - async findUserForPublicProfile(queryOptions: UserQueryOptions): Promise { + async findUserForPublicProfile(queryOptions: UserQueryOptions): Promise { return this.prisma.user.findFirst({ where: { publicProfile: true, @@ -330,7 +330,7 @@ export class UserRepository { * @returns Updates user details */ // eslint-disable-next-line camelcase - async updateUserInfo(email: string, userInfo: userInfo): Promise { + async updateUserInfo(email: string, userInfo: UserInfo): Promise { try { const updateUserDetails = await this.prisma.user.update({ where: { diff --git a/apps/user/src/user.controller.ts b/apps/user/src/user.controller.ts index 4d349587b..cd51eeb54 100644 --- a/apps/user/src/user.controller.ts +++ b/apps/user/src/user.controller.ts @@ -1,4 +1,4 @@ -import { AddPasskeyDetails, CheckUserDetails, PlatformSettings, ShareUserCertificate, UserInvitations, UpdateUserProfile, UserCredentials, UserEmailVerificationDto, userInfo, UsersProfile } from '../interfaces/user.interface'; +import { AddPasskeyDetails, CheckUserDetails, PlatformSettings, ShareUserCertificate, UserInvitations, UpdateUserProfile, UserCredentials, UserEmailVerificationDto, UserInfo, UsersProfile } from '../interfaces/user.interface'; import {IOrgUsers, Payload} from '../interfaces/user.interface'; import { AcceptRejectInvitationDto } from '../dtos/accept-reject-invitation.dto'; @@ -126,7 +126,7 @@ export class UserController { return this.userService.checkUserExist(payload.userEmail); } @MessagePattern({ cmd: 'add-user' }) - async addUserDetailsInKeyCloak(payload: { userInfo: userInfo }): Promise { + async addUserDetailsInKeyCloak(payload: { userInfo: UserInfo }): Promise { return this.userService.createUserForToken(payload.userInfo); } diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 21a0f5e0d..36e1d260f 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -38,7 +38,7 @@ import { UpdateUserProfile, UserCredentials, UserEmailVerificationDto, - userInfo, + UserInfo, UsersProfile } from '../interfaces/user.interface'; import { AcceptRejectInvitationDto } from '../dtos/accept-reject-invitation.dto'; @@ -208,7 +208,7 @@ export class UserService { } } - async createUserForToken(userInfo: userInfo): Promise { + async createUserForToken(userInfo: UserInfo): Promise { try { const { email } = userInfo; if (!userInfo.email) { From 23f6ed7328b4286b4caec6698e3f674e7fa24311 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Thu, 21 Dec 2023 20:39:11 +0530 Subject: [PATCH 2/6] refactor:users activity api Signed-off-by: pranalidhanavade --- apps/api-gateway/src/user/user.controller.ts | 4 ++-- apps/api-gateway/src/user/user.service.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/api-gateway/src/user/user.controller.ts b/apps/api-gateway/src/user/user.controller.ts index 2c1b696bc..48c8eef9a 100644 --- a/apps/api-gateway/src/user/user.controller.ts +++ b/apps/api-gateway/src/user/user.controller.ts @@ -177,13 +177,13 @@ export class UserController { @Query('limit') limit: number, @Res() res: Response, @User() reqUser: user - ): Promise { + ): Promise { const userDetails = await this.userService.getUserActivities(reqUser.id, limit); const finalResponse: IResponseType = { statusCode: HttpStatus.OK, message: ResponseMessages.user.success.userActivity, - data: userDetails.response + data: userDetails }; return res.status(HttpStatus.OK).json(finalResponse); diff --git a/apps/api-gateway/src/user/user.service.ts b/apps/api-gateway/src/user/user.service.ts index 266c96372..a077afc19 100644 --- a/apps/api-gateway/src/user/user.service.ts +++ b/apps/api-gateway/src/user/user.service.ts @@ -10,6 +10,7 @@ import { AddPasskeyDetails } from './dto/add-user.dto'; import { UpdatePlatformSettingsDto } from './dto/update-platform-settings.dto'; import { CreateUserCertificateDto } from './dto/share-certificate.dto'; import { UsersProfile } from 'apps/user/interfaces/user.interface'; +import { UsersActivity } from 'libs/user-activity/interface'; @Injectable() export class UserService extends BaseService { @@ -78,9 +79,9 @@ export class UserService extends BaseService { return this.sendNats(this.serviceProxy, 'check-user-exist', payload); } - async getUserActivities(userId: string, limit: number): Promise<{ response: object }> { + async getUserActivities(userId: string, limit: number): Promise { const payload = { userId, limit }; - return this.sendNats(this.serviceProxy, 'get-user-activity', payload); + return this.sendNatsMessage(this.serviceProxy, 'get-user-activity', payload); } async addPasskey(userEmail: string, userInfo: AddPasskeyDetails): Promise<{ response: string }> { From 71ea39a1281e4f1fbcdbb74f3459bc3fc8218320 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Sat, 23 Dec 2023 23:50:41 +0530 Subject: [PATCH 3/6] fix:comments on user profile api Signed-off-by: pranalidhanavade --- apps/api-gateway/src/user/user.controller.ts | 2 +- apps/api-gateway/src/user/user.service.ts | 8 ++++---- apps/user/interfaces/user.interface.ts | 21 +++++++++++--------- apps/user/repositories/user.repository.ts | 12 +++++------ apps/user/src/user.controller.ts | 8 ++++---- apps/user/src/user.service.ts | 10 +++++----- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/apps/api-gateway/src/user/user.controller.ts b/apps/api-gateway/src/user/user.controller.ts index 48c8eef9a..3ca48abe1 100644 --- a/apps/api-gateway/src/user/user.controller.ts +++ b/apps/api-gateway/src/user/user.controller.ts @@ -71,7 +71,7 @@ export class UserController { */ @Get('/public-profiles') @ApiExcludeEndpoint() - @ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto }) + @ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto }) @ApiOperation({ summary: 'Get users list', description: 'Get users list.' }) @ApiQuery({ name: 'pageNumber', diff --git a/apps/api-gateway/src/user/user.service.ts b/apps/api-gateway/src/user/user.service.ts index a077afc19..e9c2394ae 100644 --- a/apps/api-gateway/src/user/user.service.ts +++ b/apps/api-gateway/src/user/user.service.ts @@ -9,7 +9,7 @@ import { UpdateUserProfileDto } from './dto/update-user-profile.dto'; import { AddPasskeyDetails } from './dto/add-user.dto'; import { UpdatePlatformSettingsDto } from './dto/update-platform-settings.dto'; import { CreateUserCertificateDto } from './dto/share-certificate.dto'; -import { UsersProfile } from 'apps/user/interfaces/user.interface'; +import { IUsersProfile } from 'apps/user/interfaces/user.interface'; import { UsersActivity } from 'libs/user-activity/interface'; @Injectable() @@ -18,14 +18,14 @@ export class UserService extends BaseService { super('User Service'); } - async getProfile(id: string): Promise { + async getProfile(id: string): Promise { const payload = { id }; return this.sendNatsMessage(this.serviceProxy, 'get-user-profile', payload); } async getPublicProfile(username: string): Promise<{ response: object }> { - const payload = { username }; - return this.sendNats(this.serviceProxy, 'get-user-public-profile', payload); + const payload = { username }; + return this.sendNats(this.serviceProxy, 'get-user-public-profile', payload); } diff --git a/apps/user/interfaces/user.interface.ts b/apps/user/interfaces/user.interface.ts index c0446e58f..0f493701b 100644 --- a/apps/user/interfaces/user.interface.ts +++ b/apps/user/interfaces/user.interface.ts @@ -22,27 +22,30 @@ export interface Organisation { logoUrl: string; } -export interface UsersProfile { +export interface IUsersProfile { id?: string; username?: string; email?: string; firstName?: string; lastName?: string; supabaseUserId?: string; - userOrgRoles?: UserOrgRole[]; + userOrgRoles?: IUserOrgRole[]; } -interface UserOrgRole { +interface IUserOrgRole { id: string; userId: string; orgRoleId: string; orgId: string; - orgRole: { + orgRole :IOrgRole; + organisation:IOrganisation; +} + export interface IOrgRole{ id: string; - name: string; - description: string; + name: string; + description: string; }; - organisation: { + export interface IOrganisation{ id: string; name: string; description: string; @@ -51,7 +54,7 @@ interface UserOrgRole { website: string; publicProfile: boolean; }; -} + export interface OrgInvitations { id: string; @@ -69,7 +72,7 @@ interface UserOrgRole { username?: string; } - export interface UserInfo { + export interface IUserInformation { email: string; password: string; firstName: string; diff --git a/apps/user/repositories/user.repository.ts b/apps/user/repositories/user.repository.ts index ce4d23eca..cc5c72fea 100644 --- a/apps/user/repositories/user.repository.ts +++ b/apps/user/repositories/user.repository.ts @@ -8,8 +8,8 @@ import { UpdateUserProfile, UserCredentials, UserEmailVerificationDto, - UsersProfile, - UserInfo + IUsersProfile, + IUserInformation } from '../interfaces/user.interface'; import { InternalServerErrorException } from '@nestjs/common'; @@ -97,7 +97,7 @@ export class UserRepository { * @param id * @returns User profile data */ - async getUserById(id: string): Promise { + async getUserById(id: string): Promise { const queryOptions: UserQueryOptions = { id }; @@ -123,7 +123,7 @@ export class UserRepository { * @param id * @returns User profile data */ - async getUserPublicProfile(username: string): Promise { + async getUserPublicProfile(username: string): Promise { const queryOptions: UserQueryOptions = { username }; @@ -203,7 +203,7 @@ export class UserRepository { return this.findUser(queryOptions); } - async findUser(queryOptions: UserQueryOptions): Promise { + async findUser(queryOptions: UserQueryOptions): Promise { return this.prisma.user.findFirst({ where: { OR: [ @@ -330,7 +330,7 @@ export class UserRepository { * @returns Updates user details */ // eslint-disable-next-line camelcase - async updateUserInfo(email: string, userInfo: UserInfo): Promise { + async updateUserInfo(email: string, userInfo: IUserInformation): Promise { try { const updateUserDetails = await this.prisma.user.update({ where: { diff --git a/apps/user/src/user.controller.ts b/apps/user/src/user.controller.ts index cd51eeb54..51e28b845 100644 --- a/apps/user/src/user.controller.ts +++ b/apps/user/src/user.controller.ts @@ -1,4 +1,4 @@ -import { AddPasskeyDetails, CheckUserDetails, PlatformSettings, ShareUserCertificate, UserInvitations, UpdateUserProfile, UserCredentials, UserEmailVerificationDto, UserInfo, UsersProfile } from '../interfaces/user.interface'; +import { AddPasskeyDetails, CheckUserDetails, PlatformSettings, ShareUserCertificate, UserInvitations, UpdateUserProfile, UserCredentials, UserEmailVerificationDto, IUserInformation, IUsersProfile } from '../interfaces/user.interface'; import {IOrgUsers, Payload} from '../interfaces/user.interface'; import { AcceptRejectInvitationDto } from '../dtos/accept-reject-invitation.dto'; @@ -40,12 +40,12 @@ export class UserController { } @MessagePattern({ cmd: 'get-user-profile' }) - async getProfile(payload: { id }): Promise { + async getProfile(payload: { id }): Promise { return this.userService.getProfile(payload); } @MessagePattern({ cmd: 'get-user-public-profile' }) - async getPublicProfile(payload: { username }): Promise { + async getPublicProfile(payload: { username }): Promise { return this.userService.getPublicProfile(payload); } @MessagePattern({ cmd: 'update-user-profile' }) @@ -126,7 +126,7 @@ export class UserController { return this.userService.checkUserExist(payload.userEmail); } @MessagePattern({ cmd: 'add-user' }) - async addUserDetailsInKeyCloak(payload: { userInfo: UserInfo }): Promise { + async addUserDetailsInKeyCloak(payload: { userInfo: IUserInformation }): Promise { return this.userService.createUserForToken(payload.userInfo); } diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 36e1d260f..f679712bc 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -38,8 +38,8 @@ import { UpdateUserProfile, UserCredentials, UserEmailVerificationDto, - UserInfo, - UsersProfile + IUserInformation, + IUsersProfile } from '../interfaces/user.interface'; import { AcceptRejectInvitationDto } from '../dtos/accept-reject-invitation.dto'; import { UserActivityService } from '@credebl/user-activity'; @@ -208,7 +208,7 @@ export class UserService { } } - async createUserForToken(userInfo: UserInfo): Promise { + async createUserForToken(userInfo: IUserInformation): Promise { try { const { email } = userInfo; if (!userInfo.email) { @@ -368,7 +368,7 @@ export class UserService { } } - async getProfile(payload: { id }): Promise { + async getProfile(payload: { id }): Promise { try { const userData = await this.userRepository.getUserById(payload.id); const ecosystemSettingsList = await this.prisma.ecosystem_config.findMany({ @@ -388,7 +388,7 @@ export class UserService { } } - async getPublicProfile(payload: { username }): Promise { + async getPublicProfile(payload: { username }): Promise { try { const userProfile = await this.userRepository.getUserPublicProfile(payload.username); From a55992d6cdbb1c7f0c974ac1439d8238b73b2904 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Sun, 24 Dec 2023 00:00:54 +0530 Subject: [PATCH 4/6] fix:resolved comments of get user profile api Signed-off-by: pranalidhanavade --- apps/user/interfaces/user.interface.ts | 2 +- apps/user/repositories/user.repository.ts | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/user/interfaces/user.interface.ts b/apps/user/interfaces/user.interface.ts index 0f493701b..28ef25f61 100644 --- a/apps/user/interfaces/user.interface.ts +++ b/apps/user/interfaces/user.interface.ts @@ -23,7 +23,7 @@ export interface Organisation { } export interface IUsersProfile { - id?: string; + id: string; username?: string; email?: string; firstName?: string; diff --git a/apps/user/repositories/user.repository.ts b/apps/user/repositories/user.repository.ts index cc5c72fea..32c1d4b2e 100644 --- a/apps/user/repositories/user.repository.ts +++ b/apps/user/repositories/user.repository.ts @@ -254,7 +254,7 @@ export class UserRepository { }); } - async findUserForPublicProfile(queryOptions: UserQueryOptions): Promise { + async findUserForPublicProfile(queryOptions: UserQueryOptions): Promise { return this.prisma.user.findFirst({ where: { publicProfile: true, @@ -279,22 +279,30 @@ export class UserRepository { isEmailVerified: true, publicProfile: true, userOrgRoles: { - include: { - orgRole: true, + select:{ + id: true, + userId:true, + orgRoleId:true, + orgId:true, + orgRole: { + select:{ + id: true, + name: true, + description: true + } + }, organisation: { select: { id: true, name: true, description: true, + orgSlug:true, logoUrl: true, website: true, - orgSlug: true - }, - where: { publicProfile: true } - } } + } } } }); From 89baf0ede81f4b1f8df42dfe004c3669906be742 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Sun, 24 Dec 2023 00:15:00 +0530 Subject: [PATCH 5/6] fix:resolved comments of get user profile api Signed-off-by: pranalidhanavade --- apps/api-gateway/src/user/user.controller.ts | 2 +- apps/api-gateway/src/user/user.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api-gateway/src/user/user.controller.ts b/apps/api-gateway/src/user/user.controller.ts index 3ca48abe1..1a3c48fad 100644 --- a/apps/api-gateway/src/user/user.controller.ts +++ b/apps/api-gateway/src/user/user.controller.ts @@ -133,7 +133,7 @@ export class UserController { }) @UseGuards(AuthGuard('jwt')) @ApiBearerAuth() - async getProfile(@User() reqUser: user, @Res() res: Response): Promise { + async getProfile(@User() reqUser: user, @Res() res: Response): Promise { const userData = await this.userService.getProfile(reqUser.id); const finalResponse: IResponseType = { diff --git a/apps/api-gateway/src/user/user.service.ts b/apps/api-gateway/src/user/user.service.ts index e9c2394ae..13d7f8cbb 100644 --- a/apps/api-gateway/src/user/user.service.ts +++ b/apps/api-gateway/src/user/user.service.ts @@ -25,7 +25,7 @@ export class UserService extends BaseService { async getPublicProfile(username: string): Promise<{ response: object }> { const payload = { username }; - return this.sendNats(this.serviceProxy, 'get-user-public-profile', payload); + return this.sendNatsMessage(this.serviceProxy, 'get-user-public-profile', payload); } @@ -71,7 +71,7 @@ export class UserService extends BaseService { ): Promise<{ response: object }> { const { pageNumber, pageSize, search } = getAllUsersDto; const payload = { pageNumber, pageSize, search }; - return this.sendNats(this.serviceProxy, 'fetch-users', payload); + return this.sendNatsMessage(this.serviceProxy, 'fetch-users', payload); } async checkUserExist(userEmail: string): Promise<{ response: string }> { From 4b8a8a56beb67ae1a7bc5c1233aef97fa27d3c91 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Sun, 24 Dec 2023 00:54:38 +0530 Subject: [PATCH 6/6] refactor:user activity api summary and description Signed-off-by: pranalidhanavade --- apps/api-gateway/src/user/user.controller.ts | 6 +++--- apps/api-gateway/src/user/user.service.ts | 4 ++-- apps/user/src/user.controller.ts | 4 ++-- apps/user/src/user.service.ts | 4 ++-- libs/user-activity/interface/index.ts | 2 +- libs/user-activity/repositories/index.ts | 4 ++-- libs/user-activity/src/user-activity.service.ts | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/api-gateway/src/user/user.controller.ts b/apps/api-gateway/src/user/user.controller.ts index 1a3c48fad..a4d295757 100644 --- a/apps/api-gateway/src/user/user.controller.ts +++ b/apps/api-gateway/src/user/user.controller.ts @@ -167,8 +167,8 @@ export class UserController { @Get('/activity') @ApiOperation({ - summary: 'organization invitations', - description: 'Fetch organization invitations' + summary: 'users activity', + description: 'Fetch users activity' }) @UseGuards(AuthGuard('jwt')) @ApiBearerAuth() @@ -177,7 +177,7 @@ export class UserController { @Query('limit') limit: number, @Res() res: Response, @User() reqUser: user - ): Promise { + ): Promise { const userDetails = await this.userService.getUserActivities(reqUser.id, limit); const finalResponse: IResponseType = { diff --git a/apps/api-gateway/src/user/user.service.ts b/apps/api-gateway/src/user/user.service.ts index 13d7f8cbb..a9ff4d91a 100644 --- a/apps/api-gateway/src/user/user.service.ts +++ b/apps/api-gateway/src/user/user.service.ts @@ -10,7 +10,7 @@ import { AddPasskeyDetails } from './dto/add-user.dto'; import { UpdatePlatformSettingsDto } from './dto/update-platform-settings.dto'; import { CreateUserCertificateDto } from './dto/share-certificate.dto'; import { IUsersProfile } from 'apps/user/interfaces/user.interface'; -import { UsersActivity } from 'libs/user-activity/interface'; +import { IUsersActivity } from 'libs/user-activity/interface'; @Injectable() export class UserService extends BaseService { @@ -79,7 +79,7 @@ export class UserService extends BaseService { return this.sendNats(this.serviceProxy, 'check-user-exist', payload); } - async getUserActivities(userId: string, limit: number): Promise { + async getUserActivities(userId: string, limit: number): Promise { const payload = { userId, limit }; return this.sendNatsMessage(this.serviceProxy, 'get-user-activity', payload); } diff --git a/apps/user/src/user.controller.ts b/apps/user/src/user.controller.ts index 51e28b845..4f8770b97 100644 --- a/apps/user/src/user.controller.ts +++ b/apps/user/src/user.controller.ts @@ -8,7 +8,7 @@ import { MessagePattern } from '@nestjs/microservices'; import { UserService } from './user.service'; import { VerifyEmailTokenDto } from '../dtos/verify-email.dto'; import { user } from '@prisma/client'; -import { UsersActivity } from 'libs/user-activity/interface'; +import { IUsersActivity } from 'libs/user-activity/interface'; @Controller() export class UserController { @@ -132,7 +132,7 @@ export class UserController { // Fetch Users recent activities @MessagePattern({ cmd: 'get-user-activity' }) - async getUserActivity(payload: { userId: string, limit: number }): Promise { + async getUserActivity(payload: { userId: string, limit: number }): Promise { return this.userService.getUserActivity(payload.userId, payload.limit); } diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index f679712bc..552f9a4ca 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -55,7 +55,7 @@ import { DISALLOWED_EMAIL_DOMAIN } from '@credebl/common/common.constant'; import { AwsService } from '@credebl/aws'; import puppeteer from 'puppeteer'; import { WorldRecordTemplate } from '../templates/world-record-template'; -import { UsersActivity } from 'libs/user-activity/interface'; +import { IUsersActivity } from 'libs/user-activity/interface'; @Injectable() export class UserService { @@ -755,7 +755,7 @@ export class UserService { } - async getUserActivity(userId: string, limit: number): Promise { + async getUserActivity(userId: string, limit: number): Promise { try { return this.userActivityService.getUserActivity(userId, limit); } catch (error) { diff --git a/libs/user-activity/interface/index.ts b/libs/user-activity/interface/index.ts index d6bc0c120..87ba1685b 100644 --- a/libs/user-activity/interface/index.ts +++ b/libs/user-activity/interface/index.ts @@ -1,4 +1,4 @@ -export interface UsersActivity { +export interface IUsersActivity { id: string, orgId: string, userId: string, diff --git a/libs/user-activity/repositories/index.ts b/libs/user-activity/repositories/index.ts index 3618f188c..7ab76edfc 100644 --- a/libs/user-activity/repositories/index.ts +++ b/libs/user-activity/repositories/index.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import { Injectable, Logger } from '@nestjs/common'; -import { UsersActivity} from '../interface'; +import { IUsersActivity} from '../interface'; import { PrismaService } from '@credebl/prisma-service'; import { user_activity } from '@prisma/client'; @@ -23,7 +23,7 @@ export class UserActivityRepository { } - async getRecentActivities(userId: string, limit: number): Promise { + async getRecentActivities(userId: string, limit: number): Promise { return this.prisma.user_activity.findMany({ where: { userId diff --git a/libs/user-activity/src/user-activity.service.ts b/libs/user-activity/src/user-activity.service.ts index a84554d0a..f90f4f00a 100644 --- a/libs/user-activity/src/user-activity.service.ts +++ b/libs/user-activity/src/user-activity.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { UserActivityRepository } from '../repositories'; import { user_activity } from '@prisma/client'; -import { UsersActivity } from '../interface'; +import { IUsersActivity } from '../interface'; @Injectable() export class UserActivityService { @@ -16,7 +16,7 @@ export class UserActivityService { return this.userActivityRepository.logActivity(userId, orgId, action, details); } - async getUserActivity(userId: string, limit: number): Promise { + async getUserActivity(userId: string, limit: number): Promise { return this.userActivityRepository.getRecentActivities(userId, limit); } }