Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@GrpcMethod('NotificationService')
getLatest(data: IGetLatestRequest): Observable {
return from(this.notificationService.getLatest(
data.characterId,
data.pagination.limit,
data.pagination.page
)).pipe(
map<{ notifications: Notification[], count: number }, IPaginatedNotificationResponse>(notificationData => ({
notifications: notificationData.notifications.map(this.notificationTransform),
count: notificationData.count,
}))
);
}
@GrpcMethod('NotificationService')
markAsSeen(data: IMarkAsSeenRequest): Observable {
return from(this.notificationService.get(
data.notificationId,
data.characterId,
)).pipe(
flatMap(notification => this.notificationService.markAsSeen(notification)),
map(this.notificationTransform)
);
}
private notificationTransform(notification: Notification): INotificationResponse {
return {
id: notification.id,
createdAt: notification.createdAt.toISOString(),
seenAt: notification.seenAt.toISOString(),
type: notification.type,
import { PostService } from '@new-eden-social/services-post/post.service';
import { Observable, from } from 'rxjs';
import { Post } from '@new-eden-social/services-post/post.entity';
import { map } from 'rxjs/operators';
import { IURLMetadata } from '@new-eden-social/services-metascraper/metascraper.interface';
import { GrpcMethod } from '@nestjs/microservices';
@Controller()
export class PostGrpcController implements IPostGrpcService {
constructor(
private readonly postService: PostService,
) {
}
@GrpcMethod('PostService')
get(data: IGetRequest): Observable {
return from(this.postService.get(data.postId)).pipe(
map(this.postTransform)
);
}
@GrpcMethod('PostService')
createAsCharacter(data: ICreateAsCharacterRequest): Observable {
return from(this.postService.createAsCharacter(data.post, data.characterId)).pipe(
map(this.postTransform)
);
}
@GrpcMethod('PostService')
createAsCorporation(data: ICreateAsCorporationRequest): Observable {
return from(this.postService.createAsCorporation(data.post, data.corporationId)).pipe(
}
@GrpcMethod('PageService')
async deletePage(body: { id: number }) {
await this.pageService.deletePage(body.id);
return { code: 200, message: 'ๅ ้คๆๅ!' };
}
@GrpcMethod('PageService')
async getAllPage(body: { pageNumber: number, pageSize: number, name: string }) {
const data = (await this.pageService.getAllPage(body.pageNumber, body.pageSize, body.name)).data;
const total = (await this.pageService.getAllPage(body.pageNumber, body.pageSize, body.name)).total;
return { code: 200, message: 'ๆฅ่ฏขๆๅ!', data, total }
}
@GrpcMethod('PageService')
async getOnePage(body: { alias: string }) {
const data = await this.pageService.getOnePage(body.alias);
return { code: 200, message: 'ๆฅ่ฏขๆๅ!', data };
}
}
@GrpcMethod('CharacterService')
exists(data: IExistsGetRefreshRequest): Observable {
return from(this.characterService.exists(data.characterId)).pipe(
map(exists => ({ exists })),
);
}
@GrpcMethod('CharacterService')
get(data: IExistsGetRefreshRequest): Observable {
return from(this.characterService.get(data.characterId)).pipe(
map(this.characterTransform),
);
}
@GrpcMethod('CharacterService')
getNotUpdated(data: IGetNotUpdatedRequest): Observable {
return from(this.characterService.getNotUpdated(data.interval, data.limit)).pipe(
map(characters => ({ characters: characters.map(this.characterTransform)}))
);
}
@GrpcMethod('CharacterService')
refresh(data: IExistsGetRefreshRequest): Observable {
return from(this.characterService.get(data.characterId)).pipe(
map(this.characterTransform),
);
}
@GrpcMethod('CharacterService')
roles(data: IExistsGetRefreshRequest): Observable {
return from(this.characterService.getRoles(data.characterId)).pipe(
return { code: 200, message: t('Revert recycled user successfully') };
}
@GrpcMethod('UserService')
async updateUserInfoById(payload: { userId: number, updateUserInput: UpdateUserInput }) {
await this.userService.updateUserInfo(payload.userId, payload.updateUserInput);
return { code: 200, message: t('Update user information successfully') };
}
@GrpcMethod('UserService')
async updateCurrentUserInfo(payload: { userId: number, updateCurrentUserInput: UpdateUserInput }) {
await this.userService.updateUserInfo(payload.userId, payload.updateCurrentUserInput);
return { code: 200, message: t('Update current login user information successfully') };
}
@GrpcMethod('UserService')
async findUserInfoByIds(payload: { userIds: number[] }) {
const data = await this.userService.findUserInfoById(payload.userIds) as UserInfoData[];
return { code: 200, message: t('Query the specified users information successfully'), data };
}
@GrpcMethod('UserService')
async findCurrentUserInfo(payload: { userId: number }) {
const data = await this.userService.findUserInfoById(payload.userId) as UserInfoData;
return { code: 200, message: t('Query the current login user information successfully'), data };
}
@GrpcMethod('UserService')
async findRegisterUserInputInfo() {
const data = await this.userService.findOneWithInfoItemsByRoleIds([1]);
return { code: 200, message: t('Query user registration information item successfully'), data };
}
return { code: 200, message: 'ๆทปๅ ๆๅ!' };
}
@GrpcMethod('ClassifyService')
async delClassify(body: { id: number }) {
await this.classifyService.delClassify(body.id);
return { code: 200, message: 'ๅ ้คๆๅ!' };
}
@GrpcMethod('ClassifyService')
async updateClassify(body: { classify: Classify }) {
await this.classifyService.updateClassify(body.classify);
return { code: 200, message: 'ไฟฎๆนๆๅ!' };
}
@GrpcMethod('ClassifyService')
async getAllClassify(body: { id: number }) {
const data = await this.classifyService.getAllClassify(body.id);
return { code: 200, message: 'ๆฅ่ฏขๆๅ!', data: JSON.stringify(data) };
}
@GrpcMethod('ClassifyService')
async getOneClassify(body: { id: number }) {
const data = await this.classifyService.getOneClassify(body.id);
return { code: 200, message: 'ๆฅ่ฏขๆๅ!', data: JSON.stringify(data) };
}
@GrpcMethod('ClassifyService')
async getParentClassify(body: { id: number }) {
const data = await this.classifyService.getParentClassify(body.id);
return { code: 200, message: 'ๆฅ่ฏขๆๅ!', data };
}
data = result.usersInfo;
count = result.count;
} else {
data = result;
}
return { code: 200, message: t('Query all users successfully'), data, count };
}
@GrpcMethod('UserService')
async findUsersInRole(payload: { roleId: number, pageNumber: number, pageSize: number }) {
const { roleId, pageNumber, pageSize } = payload;
const { usersInfo, count } = await this.userService.findByRoleId(roleId, pageNumber, pageSize);
return { code: 200, message: t('Query the user under the role successfully'), data: usersInfo, count };
}
@GrpcMethod('UserService')
async findUsersInOrganization(payload: { organizationId: number, pageNumber: number, pageSize: number }) {
const { organizationId, pageNumber, pageSize } = payload;
const { usersInfo, count } = await this.userService.findByOrganizationId(organizationId, pageNumber, pageSize);
return { code: 200, message: t('Query users under the organization successfully'), data: usersInfo, count };
}
@GrpcMethod('UserService')
async findOneWithRolesAndPermissions(payload: { username: string }) {
const data = await this.userService.findOneWithRolesAndPermissions(payload.username);
return { code: 200, message: t('Query users roles and permissions successfully'), data };
}
@GrpcMethod('UserService')
async addPermissionToUser(payload: { userId: number, permissionId: number }) {
await this.userService.addPermissionToUser(payload.userId, payload.permissionId);
return { code: 200, message: t('Add permission to user successfully') };
@GrpcMethod('CharacterService')
getNotUpdated(data: IGetNotUpdatedRequest): Observable {
return from(this.characterService.getNotUpdated(data.interval, data.limit)).pipe(
map(characters => ({ characters: characters.map(this.characterTransform)}))
);
}
@GrpcMethod('CharacterService')
refresh(data: IExistsGetRefreshRequest): Observable {
return from(this.characterService.get(data.characterId)).pipe(
map(this.characterTransform),
);
}
@GrpcMethod('CharacterService')
roles(data: IExistsGetRefreshRequest): Observable {
return from(this.characterService.getRoles(data.characterId)).pipe(
map(roles => roles),
);
}
private characterTransform(character: Character): ICharacterResponse {
return {
id: character.id,
handle: character.handle,
corporationId: character.corporationId,
name: character.name,
description: character.description,
gender: character.gender,
raceId: character.raceId,
bloodlineId: character.bloodlineId,
import { Controller } from '@nestjs/common';
import { GrpcMethod } from '@nestjs/microservices';
import { BooleanPayload } from '@ultimatebackend/contracts';
@Controller()
export class PlanService {
@GrpcMethod('PlanService', 'PlanExist')
async planExist(data: { params: string[] }): Promise {
return {
success: true,
};
}
@GrpcMethod('PlanService', 'FindOne')
async findOne(data: { params: string[] }): Promise {
return {
success: true,
};
}
}
return { code: 200, message: t('Delete user to recycle bin successfully') };
}
@GrpcMethod('UserService')
async deleteRecycledUser(payload: { userId: number }) {
await this.userService.deleteUser(payload.userId);
return { code: 200, message: t('Delete user in the recycle bin successfully') };
}
@GrpcMethod('UserService')
async revertBannedUser(payload: { userId: number }) {
await this.userService.revertBannedOrRecycledUser(payload.userId, 'banned');
return { code: 200, message: t('Revert banned user successfully') };
}
@GrpcMethod('UserService')
async revertRecycledUser(payload: { userId: number }) {
await this.userService.revertBannedOrRecycledUser(payload.userId, 'recycled');
return { code: 200, message: t('Revert recycled user successfully') };
}
@GrpcMethod('UserService')
async updateUserInfoById(payload: { userId: number, updateUserInput: UpdateUserInput }) {
await this.userService.updateUserInfo(payload.userId, payload.updateUserInput);
return { code: 200, message: t('Update user information successfully') };
}
@GrpcMethod('UserService')
async updateCurrentUserInfo(payload: { userId: number, updateCurrentUserInput: UpdateUserInput }) {
await this.userService.updateUserInfo(payload.userId, payload.updateCurrentUserInput);
return { code: 200, message: t('Update current login user information successfully') };
}