"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeaturesApi = void 0;
const debug_1 = require("../../debug");
const debug = (0, debug_1.createDebug)('signalk-server:api:features');
const FEATURES_API_PATH = `/signalk/v2/features`;
class FeaturesApi {
    app;
    constructor(app) {
        this.app = app;
    }
    async start() {
        return new Promise((resolve) => {
            this.initApiRoutes();
            resolve();
        });
    }
    initApiRoutes() {
        debug(`** Initialise ${FEATURES_API_PATH} path handlers **`);
        // return Feature information
        this.app.get(`${FEATURES_API_PATH}`, async (req, res) => {
            debug(`** GET ${req.path}`);
            const enabled = ['true', '1'].includes(req.query.enabled)
                ? true
                : ['false', '0'].includes(req.query.enabled)
                    ? false
                    : undefined;
            res.json(await this.app.getFeatures(enabled));
        });
    }
}
exports.FeaturesApi = FeaturesApi;
//# sourceMappingURL=index.js.map