@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
30 lines (29 loc) • 1.47 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 });
exports.default = handle;
const util_1 = require("../../../util");
function handle(integration) {
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
if (!integration.getConfiguration) {
return res.send([]);
}
const projectId = req.crowdinContext.jwtPayload.context.project_id;
const configurationFields = yield integration.getConfiguration({
projectId,
client: req.crowdinApiClient,
credentials: req.integrationCredentials,
settings: req.integrationSettings,
clientId: req.crowdinContext.clientId,
});
res.send(configurationFields);
}));
}