refactor: add missing getAdmin API, move ApiKeyActions to utils

This commit is contained in:
Jeeiii
2024-03-27 12:28:03 +01:00
parent 64268d87c1
commit fa4792cbe0
7 changed files with 23 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
import { Body, Controller, Post, Put } from "@nestjs/common"
import { Body, Controller, Get, Param, Post, Put } from "@nestjs/common"
import { ApiCreatedResponse } from "@nestjs/swagger"
import { CreateAdminDTO } from "./dto/create-admin.dto"
import { UpdateApiKeyDTO } from "./dto/update-apikey.dto"
import { AdminsService } from "./admins.service"
@@ -13,6 +14,12 @@ export class AdminsController {
return this.adminsService.create(dto)
}
@Get(":admin")
@ApiCreatedResponse({ type: Admin })
async getAdmin(@Param("admin") adminId: string) {
return this.adminsService.findOne({ id: adminId })
}
@Put("update-apikey")
async updateApiKey(@Body() dto: UpdateApiKeyDTO): Promise<string> {
return this.adminsService.updateApiKey({

View File

@@ -2,9 +2,9 @@ import { id as idToHash } from "@ethersproject/hash"
import { ScheduleModule } from "@nestjs/schedule"
import { Test } from "@nestjs/testing"
import { TypeOrmModule } from "@nestjs/typeorm"
import { ApiKeyActions } from "@bandada/utils"
import { AdminsService } from "./admins.service"
import { Admin } from "./entities/admin.entity"
import { ApiKeyActions } from "../../types"
describe("AdminsService", () => {
const id = "1"

View File

@@ -4,10 +4,10 @@ import { BadRequestException, Injectable, Logger } from "@nestjs/common"
import { InjectRepository } from "@nestjs/typeorm"
import { FindOptionsWhere, Repository } from "typeorm"
import { v4 } from "uuid"
import { ApiKeyActions } from "@bandada/utils"
import { CreateAdminDTO } from "./dto/create-admin.dto"
import { Admin } from "./entities/admin.entity"
import { UpdateApiKeyDTO } from "./dto/update-apikey.dto"
import { ApiKeyActions } from "../../types"
@Injectable()
export class AdminsService {

View File

@@ -1,5 +1,5 @@
import { IsEnum, IsString } from "class-validator"
import { ApiKeyActions } from "../../../types"
import { ApiKeyActions } from "@bandada/utils"
export class UpdateApiKeyDTO {
@IsString()

View File

@@ -1,6 +1,7 @@
import { ScheduleModule } from "@nestjs/schedule"
import { Test } from "@nestjs/testing"
import { TypeOrmModule } from "@nestjs/typeorm"
import { ApiKeyActions } from "@bandada/utils"
import { Invite } from "../invites/entities/invite.entity"
import { InvitesService } from "../invites/invites.service"
import { OAuthAccount } from "../credentials/entities/credentials-account.entity"
@@ -10,7 +11,6 @@ import { GroupsService } from "./groups.service"
import { AdminsService } from "../admins/admins.service"
import { AdminsModule } from "../admins/admins.module"
import { Admin } from "../admins/entities/admin.entity"
import { ApiKeyActions } from "../../types"
import { CreateGroupDto } from "./dto/create-group.dto"
import { UpdateGroupDto } from "./dto/update-group.dto"

View File

@@ -1,10 +0,0 @@
/**
* Defines the possible actions that can be performed on an API key.
* This includes generating a new API key, enabling an existing API key,
* and disabling an existing API key.
*/
export enum ApiKeyActions {
Generate = "generate",
Enable = "enable",
Disable = "disable"
}

View File

@@ -12,3 +12,14 @@ export type BlockchainNetwork = {
id: string
name: string
}
/**
* Defines the possible actions that can be performed on an API key.
* This includes generating a new API key, enabling an existing API key,
* and disabling an existing API key.
*/
export enum ApiKeyActions {
Generate = "generate",
Enable = "enable",
Disable = "disable"
}