unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
36 lines • 1.69 kB
JavaScript
import { NONE } from '../../types/permissions.js';
import Controller from '../controller.js';
import { createRequestSchema } from '../../openapi/util/create-request-schema.js';
import { getStandardResponses, } from '../../openapi/index.js';
export default class ConstraintController extends Controller {
constructor(config, { featureToggleService, openApiService, }) {
super(config);
this.featureService = featureToggleService;
this.openApiService = openApiService;
this.logger = config.getLogger('/admin-api/validation.ts');
this.route({
method: 'post',
path: '/validate',
handler: this.validateConstraint,
permission: NONE,
middleware: [
openApiService.validPath({
tags: ['Features'],
operationId: 'validateConstraint',
requestBody: createRequestSchema('constraintSchema'),
summary: 'Validate constraint',
description: 'Validates a constraint definition. Checks whether the context field exists and whether the applied configuration is valid. Additional properties are not allowed on data objects that you send to this endpoint.',
responses: {
204: { description: 'The constraint is valid' },
...getStandardResponses(400, 401, 403, 415),
},
}),
],
});
}
async validateConstraint(req, res) {
await this.featureService.validateConstraint(req.body);
res.status(204).send();
}
}
//# sourceMappingURL=constraints.js.map