@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
22 lines (21 loc) • 1.06 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = register;
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
const util_1 = require("../../util");
function register({ config, app }) {
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
if (!config.chat) {
return;
}
config.chat.forEach((chat, index) => {
if ((chat === null || chat === void 0 ? void 0 : chat.uiPath) || (chat === null || chat === void 0 ? void 0 : chat.formSchema)) {
const moduleKey = chat.key || `${config.identifier}-chat-${index}`;
app.use(`/chat-${moduleKey}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: moduleKey }), (0, render_ui_module_1.default)(chat, config));
}
});
}