"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sharedConfig = void 0;
const type_is_1 = __importDefault(require("type-is"));
const expresskit_1 = require("@gravity-ui/expresskit");
const apply_app_env_to_config_1 = require("../utils/configs/apply-app-env-to-config");
const path = require('path');
exports.sharedConfig = {
    appName: 'YTSaurus',
    appSocket: 'dist/run/server.sock',
    expressBodyParserJSONConfig: {
        strict: false,
        type(req) {
            // Disable JSON parser on yt-api to allow requests piping
            if (req.url?.startsWith('/api/yt/'))
                return false;
            // Simulate default logic given that 'type' option is 'application/json'
            return Boolean((0, type_is_1.default)(req, 'application/json'));
        },
    },
    expressBodyParserURLEncodedConfig: {
        type(req) {
            // Disable urlencoded parser on yt-api
            if (req.url?.startsWith('/api/yt/'))
                return false;
            // Simulate default logic given that 'type' option is 'application/x-www-form-urlencoded'
            return Boolean((0, type_is_1.default)(req, 'application/x-www-form-urlencoded'));
        },
    },
    expressBodyParserRawConfig: {
        limit: '21mb',
        type(req) {
            // Enable raw parser for all content-types on yt-api
            if (req.url?.startsWith('/api/yt/'))
                return true;
            // Simulate default logic given that 'type' option is 'multiform-data'
            return Boolean((0, type_is_1.default)(req, 'multipart/form-data'));
        },
    },
};
const config = (0, apply_app_env_to_config_1.applyAppEnvToConfig)({
    ...exports.sharedConfig,
    appAuthPolicy: expresskit_1.AuthPolicy.required,
    // TODO: fix me
    // csp: 'disabled',
    ytInterfaceSecret: path.resolve(__dirname, '../../../secrets/yt-interface-secret.json'),
    clustersConfigPath: path.resolve(__dirname, '../../../clusters-config.json'),
    uiSettings: {
        reHashFromNodeVersion: '[^~]+~(?<hash>[^+]+)',
        directDownload: true,
    },
});
exports.default = config;
