Skip to content

Commit

Permalink
fix(tenant-management): make changes to api
Browse files Browse the repository at this point in the history
make chnages to api

GH-45
  • Loading branch information
Surbhi-sharma1 committed Sep 30, 2024
1 parent 395971b commit e4658f6
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,33 @@ 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',
},
},
},
},
},
},
},
})
async getTenantKeys(
@param.filter(Tenant) filter?: Filter<Tenant>,
): Promise<string[]> {
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};
}
}

0 comments on commit e4658f6

Please sign in to comment.