@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
36 lines (35 loc) • 1.76 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = require("../../../util/logger");
const util_1 = require("../../../util");
function getInputSchemaHandler(automationAction) {
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
var _a;
try {
let result = {};
if (automationAction.validateSettings) {
result = yield automationAction.validateSettings({
client: req.crowdinApiClient,
settings: ((_a = req === null || req === void 0 ? void 0 : req.body) === null || _a === void 0 ? void 0 : _a.settings) || [],
context: req.crowdinContext,
req: req.body,
});
}
res.json({ data: result });
}
catch (error) {
req.logError(error);
res.status(500).send({ error: { message: (0, logger_1.getErrorMessage)(error) } });
}
}));
}
exports.default = getInputSchemaHandler;