All files / src/lib/routes/client-api index.ts

100% Statements 16/16
100% Branches 1/1
100% Functions 2/2
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  59x 59x 59x 59x     59x   59x   59x   141x   141x 141x 141x 141x   141x 141x               1x       59x  
import { Request, Response } from 'express';
import Controller from '../controller';
import FeatureController from './feature';
import MetricsController from './metrics';
import RegisterController from './register';
import { IUnleashConfig } from '../../types/option';
import { IUnleashServices } from '../../types';
import { SegmentsController } from './segments';
 
const apiDef = require('./api-def.json');
 
export default class ClientApi extends Controller {
    constructor(config: IUnleashConfig, services: IUnleashServices) {
        super(config);
 
        this.get('/', this.index);
        this.use('/features', new FeatureController(services, config).router);
        this.use('/metrics', new MetricsController(services, config).router);
        this.use('/register', new RegisterController(services, config).router);
 
        if (config.experimental?.segments?.enableSegmentsClientApi) {
            this.use(
                '/segments',
                new SegmentsController(services, config).router,
            );
        }
    }
 
    index(req: Request, res: Response): void {
        res.json(apiDef);
    }
}
 
module.exports = ClientApi;