UNPKG

sp-rest-proxy

Version:

SharePoint REST API Proxy for Node.js and Express local serve

47 lines 2.16 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SoapRouter = void 0; var BasicRouter_1 = require("../BasicRouter"); var headers_1 = require("../../utils/headers"); var SoapRouter = (function (_super) { __extends(SoapRouter, _super); function SoapRouter(context, settings) { var _this = _super.call(this, context, settings) || this; _this.router = function (req, res) { var endpointUrl = _this.url.apiEndpoint(req); _this.logger.info('\nPOST (SOAP): ' + endpointUrl); var body = ''; req.on('data', function (chunk) { return body += chunk; }); req.on('end', function () { if (req.headers.origin) { var regExpOrigin = new RegExp(req.headers.origin, 'g'); body = body.replace(regExpOrigin, _this.ctx.siteUrl); } var headers = (0, headers_1.getHeaders)(req.headers); _this.sp.fetch(endpointUrl, { method: 'POST', headers: headers, body: body }) .then(_this.handlers.isOK) .then(_this.handlers.response(res)) .catch(_this.handlers.error(res)); }); }; return _this; } return SoapRouter; }(BasicRouter_1.BasicRouter)); exports.SoapRouter = SoapRouter; //# sourceMappingURL=soap.js.map