unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
39 lines • 1.99 kB
JavaScript
import Controller from '../controller.js';
import { NONE } from '../../types/permissions.js';
import { createResponseSchema } from '../../openapi/util/create-response-schema.js';
import { createRequestSchema } from '../../openapi/util/create-request-schema.js';
import { validatedEdgeTokensSchema, } from '../../openapi/spec/validated-edge-tokens-schema.js';
import { getStandardResponses } from '../../openapi/util/standard-responses.js';
export default class EdgeController extends Controller {
constructor(config, { edgeService, openApiService, }) {
super(config);
this.logger = config.getLogger('edge-api/index.ts');
this.edgeService = edgeService;
this.openApiService = openApiService;
this.route({
method: 'post',
path: '/validate',
handler: this.getValidTokens,
permission: NONE,
middleware: [
this.openApiService.validPath({
tags: ['Unleash Edge'],
security: [{}],
summary: 'Check which tokens are valid',
description: 'This operation accepts a list of tokens to validate. Unleash will validate each token you provide. For each valid token you provide, Unleash will return the token along with its type and which projects it has access to.',
operationId: 'getValidTokens',
requestBody: createRequestSchema('tokenStringListSchema'),
responses: {
200: createResponseSchema('validatedEdgeTokensSchema'),
...getStandardResponses(400, 413, 415),
},
}),
],
});
}
async getValidTokens(req, res) {
const tokens = await this.edgeService.getValidTokens(req.body.tokens);
this.openApiService.respondWithValidation(200, res, validatedEdgeTokensSchema.$id, tokens);
}
}
//# sourceMappingURL=index.js.map