unleash-server
Version:
Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.
63 lines • 2.99 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const controller_1 = __importDefault(require("../../controller"));
const permissions_1 = require("../../../types/permissions");
const create_response_schema_1 = require("../../../openapi/util/create-response-schema");
const health_overview_schema_1 = require("../../../openapi/spec/health-overview-schema");
const serialize_dates_1 = require("../../../types/serialize-dates");
const health_report_schema_1 = require("../../../openapi/spec/health-report-schema");
class ProjectHealthReport extends controller_1.default {
constructor(config, { projectHealthService, openApiService, }) {
super(config);
this.logger = config.getLogger('/admin-api/project/health-report');
this.projectHealthService = projectHealthService;
this.openApiService = openApiService;
this.route({
method: 'get',
path: '/:projectId',
handler: this.getProjectHealthOverview,
permission: permissions_1.NONE,
middleware: [
openApiService.validPath({
tags: ['Projects'],
operationId: 'getProjectHealthOverview',
responses: {
200: (0, create_response_schema_1.createResponseSchema)('healthOverviewSchema'),
},
}),
],
});
this.route({
method: 'get',
path: '/:projectId/health-report',
handler: this.getProjectHealthReport,
permission: permissions_1.NONE,
middleware: [
openApiService.validPath({
tags: ['Projects'],
operationId: 'getProjectHealthReport',
responses: {
200: (0, create_response_schema_1.createResponseSchema)('healthReportSchema'),
},
}),
],
});
}
async getProjectHealthOverview(req, res) {
const { projectId } = req.params;
const { archived } = req.query;
const { user } = req;
const overview = await this.projectHealthService.getProjectOverview(projectId, archived, user.id);
this.openApiService.respondWithValidation(200, res, health_overview_schema_1.healthOverviewSchema.$id, (0, serialize_dates_1.serializeDates)(overview));
}
async getProjectHealthReport(req, res) {
const { projectId } = req.params;
const overview = await this.projectHealthService.getProjectHealthReport(projectId);
this.openApiService.respondWithValidation(200, res, health_report_schema_1.healthReportSchema.$id, (0, serialize_dates_1.serializeDates)(overview));
}
}
exports.default = ProjectHealthReport;
//# sourceMappingURL=health-report.js.map