@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
48 lines (47 loc) • 2.28 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
const validate_1 = __importDefault(require("./handlers/validate"));
function register({ config, app }) {
const qaCheck = config.externalQaCheck;
if (!qaCheck) {
return;
}
if (qaCheck === null || qaCheck === void 0 ? void 0 : qaCheck.batchSize) {
app.use('/qa-check/batch-size', json_response_1.default, (req, res) => {
res.send({ data: { size: qaCheck.batchSize } });
});
// TEMPORARY CODE: it needs to support old path
app.use('/batch-size', json_response_1.default, (req, res) => {
res.send({ data: { size: qaCheck.batchSize } });
});
// END TEMPORARY CODE
}
app.use('/qa-check/validate', json_response_1.default, (0, crowdin_client_1.default)({
config,
optional: false,
checkSubscriptionExpiration: true,
moduleKey: qaCheck.key,
}), (0, validate_1.default)(qaCheck));
// TEMPORARY CODE: it needs to support old path
app.use('/validate', json_response_1.default, (0, crowdin_client_1.default)({
config,
optional: false,
checkSubscriptionExpiration: true,
}), (0, validate_1.default)(qaCheck));
// END TEMPORARY CODE
if (qaCheck.settingsUiModule) {
app.use('/qa-check/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
// TEMPORARY CODE: it needs to support old path
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
// END TEMPORARY CODE
}
}
exports.register = register;