Skip to content

Commit

Permalink
feat(tenant-mgmt-facade): add api for getting tenant details
Browse files Browse the repository at this point in the history
add api for getting tenant details

GH-3
  • Loading branch information
Surbhi-sharma1 committed Sep 5, 2024
1 parent 5c69886 commit 91c8167
Show file tree
Hide file tree
Showing 4 changed files with 338 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
{ name: "audit-service-service" },
{ name: "authentication-service-service" },
{ name: "notification-service-service" },
{ name: "my-facade-facade" },
{ name: "tenant-mgmt-facade" },
{ name: "subscription-service-service" },
{ name: "tnt-mngmt-service" },
{ name: "ci-cd" },
Expand Down
29 changes: 29 additions & 0 deletions facades/tenant-mgmt-facade/src/controllers/tenant.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {inject, service} from '@loopback/core';
import {TenantHelperService} from '../services';
import {LeadUser} from '@sourceloop/ctrl-plane-tenant-management-service';
import {SubscriptionBillDTO} from '../models/dtos/subscription-bill-dto.model';
import { AnyObject } from '@loopback/repository';

export class TenantController {
constructor(
Expand Down Expand Up @@ -89,4 +90,32 @@ export class TenantController {
): Promise<SubscriptionBillDTO[]> {
return this.tenantHelper.getTenantBills(currentUser.id);
}
// Get All Tenants
@authorize({
permissions: [PermissionKey.ViewTenant],
})
@authenticate(STRATEGY.BEARER, {
passReqToCallback: true,
})
@get('/tenants', {
description: 'Retrieve all tenants',
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'Array of Tenant instances',
content: {
[CONTENT_TYPE.JSON]: {
schema: {
type: 'array',
items: getModelSchemaRef(Tenant, {includeRelations: true}),
},
},
},
},
},
})
async findTenants( @inject(AuthenticationBindings.CURRENT_USER)
currentUser: LeadUser,): Promise<AnyObject> {
return this.tenantHelper.getAllTenants(currentUser.id);
}
}
Loading

0 comments on commit 91c8167

Please sign in to comment.