-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🔥 [EXL-77] support secret management page (#315)
- Loading branch information
Showing
69 changed files
with
1,716 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apps/backend/src/modules/user/modules/secrets/available-label.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Controller, Get, HttpCode, HttpStatus, Logger, Param } from '@nestjs/common'; | ||
import { QueryBus } from '@nestjs/cqrs'; | ||
import { | ||
ApiBearerAuth, | ||
ApiInternalServerErrorResponse, | ||
ApiOkResponse, | ||
ApiOperation, | ||
ApiTags, | ||
ApiUnauthorizedResponse, | ||
} from '@nestjs/swagger'; | ||
|
||
import { CurrentUserId } from '@/decorators/current-user-id.decorator'; | ||
|
||
import Routes from './secrets.routes'; | ||
import { AvailableLabelResponse } from './classes/responses'; | ||
import { AvailableLabelContract } from './queries/contracts/available-label.contract'; | ||
|
||
@ApiTags('Secrets') | ||
@Controller(Routes.CONTROLLER) | ||
export class AvailableLabelController { | ||
private readonly logger = new Logger(AvailableLabelController.name); | ||
|
||
constructor(private readonly queryBus: QueryBus) {} | ||
|
||
@ApiOperation({ description: 'Check whether a provided label is availble' }) | ||
@ApiBearerAuth('access-token') | ||
@ApiOkResponse({ | ||
description: 'Returns whether the provided label is available', | ||
type: AvailableLabelResponse, | ||
}) | ||
@ApiUnauthorizedResponse({ | ||
description: 'If access token is invalid or missing', | ||
}) | ||
@ApiInternalServerErrorResponse({ description: 'If get availability status of the label' }) | ||
@Get(Routes.AVAILABLE_LABEL) | ||
@HttpCode(HttpStatus.OK) | ||
public async availableLabel( | ||
@CurrentUserId() userId: string, | ||
@Param('label') label: string, | ||
): Promise<AvailableLabelResponse> { | ||
this.logger.log(`Will try to get availability status of label: "${label}" with an Id: "${userId}"`); | ||
|
||
const isAvailable = await this.queryBus.execute<AvailableLabelContract, boolean>( | ||
new AvailableLabelContract(userId, label), | ||
); | ||
|
||
this.logger.log(`Successfully got availability status of label: "${label}" with an Id: "${userId}"`); | ||
|
||
return { | ||
isAvailable, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
apps/backend/src/modules/user/modules/secrets/interfaces/user-secrets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export interface IUserSecretsGetAll { | ||
readonly id: string; | ||
readonly label: string; | ||
readonly expiration: number; | ||
readonly createdAt: number; | ||
readonly expiration: number | null; | ||
} |
3 changes: 3 additions & 0 deletions
3
apps/backend/src/modules/user/modules/secrets/queries/contracts/available-label.contract.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class AvailableLabelContract { | ||
constructor(public readonly userId: string, public readonly label: string) {} | ||
} |
14 changes: 14 additions & 0 deletions
14
apps/backend/src/modules/user/modules/secrets/queries/handlers/available-label.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs'; | ||
|
||
import { DBClientSecretService } from '@/modules/database/client-secret.service'; | ||
|
||
import { AvailableLabelContract } from '../contracts/available-label.contract'; | ||
|
||
@QueryHandler(AvailableLabelContract) | ||
export class AvailableLabelHandler implements IQueryHandler<AvailableLabelContract> { | ||
constructor(private readonly dbClientSecretsService: DBClientSecretService) {} | ||
|
||
execute(contract: AvailableLabelContract) { | ||
return this.dbClientSecretsService.isLabelAvailable(contract.userId, contract.label); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
apps/backend/src/modules/user/modules/secrets/queries/handlers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { AvailableLabelHandler } from './available-label.handler'; | ||
import { CreateSecretHandler } from './create-secret.handler'; | ||
import { GetAllSecretsHandler } from './get-all-secrets.handler'; | ||
import { RefreshSecretHandler } from './refresh-secret.handler'; | ||
|
||
export const QueryHandlers = [CreateSecretHandler, RefreshSecretHandler, GetAllSecretsHandler]; | ||
export const QueryHandlers = [ | ||
CreateSecretHandler, | ||
RefreshSecretHandler, | ||
GetAllSecretsHandler, | ||
AvailableLabelHandler, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
to: src/components/ui/V<%= h.changeCase.pascalCase(name.toLowerCase()) %>/V<%= h.changeCase.pascalCase(name.toLowerCase()) %>.module.scss | ||
to: src/components/ui/ED<%= h.changeCase.pascalCase(name.toLowerCase()) %>/ED<%= h.changeCase.pascalCase(name.toLowerCase()) %>.module.scss | ||
--- |
15 changes: 0 additions & 15 deletions
15
apps/frontend/_templates/component/new-ui/component.test.tsx.t
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.