@sourceloop/ctrl-plane-tenant-management-service
Version:
Tenant Management microservice for SaaS control plane
40 lines (37 loc) • 1.06 kB
text/typescript
import {get} from '@loopback/openapi-v3';
import * as fs from 'fs';
import * as path from 'path';
import {inject} from '@loopback/context';
import {RestBindings, Response} from '@loopback/rest';
import {authorize} from 'loopback4-authorization';
import {STATUS_CODE} from '@sourceloop/core';
export class HomePageController {
private readonly html: string;
constructor(
(RestBindings.Http.RESPONSE)
private readonly response: Response,
) {
this.html = fs.readFileSync(
path.join(__dirname, '../../public/index.html'),
'utf-8',
);
// Replace base path placeholder from env
this.html = this.html.replace(
/\$\{basePath\}/g,
process.env.BASE_PATH ?? '',
);
}
({permissions: ['*']})
('/', {
responses: {
[STATUS_CODE.OK]: {
description: 'Home Page',
content: {'text/html': {schema: {type: 'string'}}},
},
},
})
homePage() {
this.response.status(STATUS_CODE.OK).contentType('html').send(this.html);
return this.response;
}
}