@sourceloop/ctrl-plane-tenant-management-service
Version:
Tenant Management microservice for SaaS control plane
41 lines (39 loc) • 1.3 kB
text/typescript
import {repository} from '@loopback/repository';
import {param, get, getModelSchemaRef} from '@loopback/rest';
import {TenantMgmtConfig, Tenant} from '../models';
import {TenantMgmtConfigRepository} from '../repositories';
import {authenticate, STRATEGY} from 'loopback4-authentication';
import {authorize} from 'loopback4-authorization';
import {PermissionKey} from '../permissions';
import {OPERATION_SECURITY_SPEC, STATUS_CODE} from '@sourceloop/core';
const basePath = '/tenant-configs/{id}/tenant';
export class TenantMgmtConfigTenantController {
constructor(
(TenantMgmtConfigRepository)
public tenantConfigRepository: TenantMgmtConfigRepository,
) {}
({
permissions: [PermissionKey.ViewTenantConfig],
})
(STRATEGY.BEARER, {
passReqToCallback: true,
})
(`${basePath}`, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'Tenant belonging to TenantConfig',
content: {
'application/json': {
schema: getModelSchemaRef(Tenant),
},
},
},
},
})
async getTenant(
.path.string('id') id: typeof TenantMgmtConfig.prototype.id,
): Promise<Tenant> {
return this.tenantConfigRepository.tenant(id);
}
}