From e4658f656fccdb409c178773986b4c3ca8c6a089 Mon Sep 17 00:00:00 2001 From: Surbhi-sharma1 Date: Mon, 30 Sep 2024 20:17:48 +0530 Subject: [PATCH] fix(tenant-management): make changes to api make chnages to api GH-45 --- .../src/controllers/tenant.controller.ts | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/services/tenant-management-service/src/controllers/tenant.controller.ts b/services/tenant-management-service/src/controllers/tenant.controller.ts index b343dcd..06932d3 100644 --- a/services/tenant-management-service/src/controllers/tenant.controller.ts +++ b/services/tenant-management-service/src/controllers/tenant.controller.ts @@ -289,17 +289,19 @@ export class TenantController { @authorize({ permissions: ['*'], }) - @get(`tenant/keys`, { + @get('verify-key/{key}', { security: OPERATION_SECURITY_SPEC, responses: { [STATUS_CODE.OK]: { - description: 'Array of Tenant keys', + description: 'Check if key exists for any Tenant', content: { [CONTENT_TYPE.JSON]: { schema: { - type: 'array', - items: { - type: 'string', + type: 'object', + properties: { + exists: { + type: 'boolean', + }, }, }, }, @@ -307,10 +309,13 @@ export class TenantController { }, }, }) - async getTenantKeys( - @param.filter(Tenant) filter?: Filter, - ): Promise { - const tenants = await this.tenantRepository.find(filter); - return tenants.map((tenant: Tenant) => tenant.key); + async checkKeyExists( + @param.path.string('key') key: string, + ): Promise<{exists: boolean}> { + const tenantKeyExists = await this.tenantRepository.findOne({ + where: {key: key}, + }); + + return {exists: !!tenantKeyExists}; } }