Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
common filters + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceowater committed Aug 7, 2024
1 parent 6d4367a commit 5e2ef62
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 64 deletions.
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@nestjs/graphql": "^12.2.0",
"@nestjs/microservices": "^10.3.10",
"@nestjs/platform-express": "^10.0.0",
"@pieceowater-dev/lotof.lib.broadcaster": "^1.0.20",
"@pieceowater-dev/lotof.lib.broadcaster": "^1.0.31",
"amqp-connection-manager": "^4.1.14",
"amqplib": "^0.10.4",
"apollo-server-express": "^3.13.0",
Expand Down
3 changes: 1 addition & 2 deletions src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// src/app.service.ts
import { Inject, Injectable } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
Expand Down
4 changes: 1 addition & 3 deletions src/core/health/health.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { UsersGateMicroservicesProvider } from '../microservices/microservices.u

@Resolver()
export class HealthResolver {
constructor(
private usersProvider: UsersGateMicroservicesProvider,
) {}
constructor(private usersProvider: UsersGateMicroservicesProvider) {}

@Query(() => String)
async health(): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion src/services/users/dto/list-user.filter.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { InputType } from '@nestjs/graphql';
import { DefaultFilterInput } from '../../utils/default.filter/default.filter.input';

@InputType()
export class ListUserFilterInput extends DefaultFilterInput {}
export class ListUserFilterInput extends DefaultFilterInput {}
2 changes: 1 addition & 1 deletion src/services/users/entities/paginated.user-list.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { User } from './user.entity';
import { PaginatedList } from '../../utils/paginated.list/paginated.list';

@ObjectType()
export class PaginatedUserList extends PaginatedList(User) {}
export class PaginatedUserList extends PaginatedList(User) {}
2 changes: 1 addition & 1 deletion src/services/users/users.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
import { UpdateUserInput } from './dto/update-user.input';
import { PaginatedUserList } from './entities/paginated.user-list.entity';
import { ListUserFilterInput } from './dto/list-user.filter.input';
import { PaginatedEntity } from '../utils/paginated.list/paginated.entity';
import { PaginatedEntity } from '@pieceowater-dev/lotof.lib.broadcaster/utils/pagination/entity.pagination';

@Resolver(() => User)
export class UsersResolver {
Expand Down
8 changes: 5 additions & 3 deletions src/services/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { CreateUserInput } from './dto/create-user.input';
import { Observable } from 'rxjs';
import { User } from './entities/user.entity';
import { ListUserFilterInput } from './dto/list-user.filter.input';
import { PaginatedEntity } from '../utils/paginated.list/paginated.entity';
import { UpdateUserInput } from './dto/update-user.input';
import { UsersGateMicroservicesProvider } from '../../core/microservices/microservices.users-provider';
import { Injectable } from '@nestjs/common';
import { ID } from '../utils/ID';
import { UserUuid } from '../utils/user/user-uuid';
import { PaginatedEntity } from '@pieceowater-dev/lotof.lib.broadcaster/utils/pagination/entity.pagination';

@Injectable()
export class UsersService {
Expand All @@ -29,7 +29,9 @@ export class UsersService {
}

async findOne(id: string): Promise<Observable<User>> {
return this.usersProvider.sendWithTimeout<User, ID>('findOneUser', { id });
return this.usersProvider.sendWithTimeout<User, UserUuid>('findOneUser', {
id,
});
}

async update(
Expand Down
3 changes: 0 additions & 3 deletions src/services/utils/ID.ts

This file was deleted.

12 changes: 4 additions & 8 deletions src/services/utils/default.filter/default.filter.input.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { Field, InputType } from '@nestjs/graphql';
import {
DefaultFilterPaginationInput,
FilterPaginationLengthEnum,
} from './default.filter.pagination.input';
import {
DefaultFilterSortInput,
FilterSortByEnum,
} from './default.filter.sort.input';
import { DefaultFilterPaginationInput } from './default.filter.pagination.input';
import { DefaultFilterSortInput } from './default.filter.sort.input';
import { FilterPaginationLengthEnum } from '@pieceowater-dev/lotof.lib.broadcaster/utils/filter/pagination.filter';
import { FilterSortByEnum } from '@pieceowater-dev/lotof.lib.broadcaster/utils/filter/sort.filter';

@InputType()
export class DefaultFilterInput {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
import { Field, InputType, registerEnumType } from '@nestjs/graphql';

export enum FilterPaginationLengthEnum {
TEN = 10,
FIFTEEN = 15,
TWENTY = 20,
TWENTY_FIVE = 25,
THIRTY = 30,
THIRTY_FIVE = 35,
FORTY = 40,
FORTY_FIVE = 45,
FIFTY = 50,
FIFTY_FIVE = 55,
SIXTY = 60,
SIXTY_FIVE = 65,
SEVENTY = 70,
SEVENTY_FIVE = 75,
EIGHTY = 80,
EIGHTY_FIVE = 85,
NINETY = 90,
NINETY_FIVE = 95,
ONE_HUNDRED = 100,
}
import { FilterPaginationLengthEnum } from '@pieceowater-dev/lotof.lib.broadcaster/utils/filter/pagination.filter';

registerEnumType(FilterPaginationLengthEnum, {
name: 'FilterPaginationLengthEnum',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Field, InputType, registerEnumType } from '@nestjs/graphql';

export enum FilterSortByEnum {
ASC = 'ASC',
DESC = 'DESC',
}
import { FilterSortByEnum } from '@pieceowater-dev/lotof.lib.broadcaster/utils/filter/sort.filter';

registerEnumType(FilterSortByEnum, {
name: 'FilterSortByEnum',
Expand Down
8 changes: 0 additions & 8 deletions src/services/utils/paginated.list/paginated.entity.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/services/utils/paginated.list/paginated.list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ObjectType, Field, Int } from '@nestjs/graphql';
import { PaginatedEntity } from './paginated.entity';
import { Type } from '@nestjs/common';
import { PaginatedEntity } from '@pieceowater-dev/lotof.lib.broadcaster/utils/pagination/entity.pagination';

export function PaginatedList<T>(classRef: Type<T>): Type<PaginatedEntity<T>> {
@ObjectType(`${classRef.name}Info`)
Expand Down
3 changes: 3 additions & 0 deletions src/services/utils/user/user-uuid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface UserUuid {
id: string;
}

0 comments on commit 5e2ef62

Please sign in to comment.