Skip to content

Commit

Permalink
refactor(server): use cascades for keys and tokens (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 committed May 23, 2023
1 parent e2bd7e1 commit 50a792a
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 128 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { APIKeyEntity } from '@app/infra/entities';

export class APIKeyCreateResponseDto {
secret!: string;
apiKey!: APIKeyResponseDto;
}

export class APIKeyResponseDto {
id!: string;
name!: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ export class APIKeyCreateDto {
@IsOptional()
name?: string;
}

export class APIKeyUpdateDto {
@IsString()
@IsNotEmpty()
name!: string;
}
1 change: 0 additions & 1 deletion server/libs/domain/src/api-key/api-key.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface IKeyRepository {
create(dto: Partial<APIKeyEntity>): Promise<APIKeyEntity>;
update(userId: string, id: string, dto: Partial<APIKeyEntity>): Promise<APIKeyEntity>;
delete(userId: string, id: string): Promise<void>;
deleteAll(userId: string): Promise<void>;
/**
* Includes the hashed `key` for verification
* @param id
Expand Down
5 changes: 2 additions & 3 deletions server/libs/domain/src/api-key/api-key.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
import { AuthUserDto } from '../auth';
import { ICryptoRepository } from '../crypto';
import { APIKeyCreateResponseDto, APIKeyResponseDto, mapKey } from './api-key-response.dto';
import { APIKeyCreateDto } from './api-key.dto';
import { IKeyRepository } from './api-key.repository';
import { APIKeyCreateDto } from './dto/api-key-create.dto';
import { APIKeyCreateResponseDto } from './response-dto/api-key-create-response.dto';
import { APIKeyResponseDto, mapKey } from './response-dto/api-key-response.dto';

@Injectable()
export class APIKeyService {
Expand Down
7 changes: 0 additions & 7 deletions server/libs/domain/src/api-key/dto/api-key-update.dto.ts

This file was deleted.

2 changes: 0 additions & 2 deletions server/libs/domain/src/api-key/dto/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions server/libs/domain/src/api-key/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './api-key-response.dto';
export * from './api-key.dto';
export * from './api-key.repository';
export * from './api-key.service';
export * from './dto';
export * from './response-dto';

This file was deleted.

2 changes: 0 additions & 2 deletions server/libs/domain/src/api-key/response-dto/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion server/libs/domain/src/user-token/user-token.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface IUserTokenRepository {
create(dto: Partial<UserTokenEntity>): Promise<UserTokenEntity>;
save(dto: Partial<UserTokenEntity>): Promise<UserTokenEntity>;
delete(userId: string, id: string): Promise<void>;
deleteAll(userId: string): Promise<void>;
getByToken(token: string): Promise<UserTokenEntity | null>;
getAll(userId: string): Promise<UserTokenEntity[]>;
}
Loading

0 comments on commit 50a792a

Please sign in to comment.