Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Mönkkönen authored and Jarkko Mönkkönen committed Oct 30, 2024
1 parent 705cddb commit c3ec55f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
14 changes: 7 additions & 7 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ var _2 = _interopRequireDefault(require("./"));
var _fp = _interopRequireDefault(require("lodash/fp"));
var _prependHttp = _interopRequireDefault(require("prepend-http"));
var _url = _interopRequireDefault(require("url"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function run() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
Expand Down
20 changes: 10 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ var _fp = _interopRequireDefault(require("lodash/fp"));
var _express = _interopRequireDefault(require("express"));
var _mimeTypes = _interopRequireDefault(require("mime-types"));
var _mockdate = _interopRequireDefault(require("mockdate"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*!
* @license
* console-log-server v0.3.0 (https://github.com/jamonkko/console-log-server#readme)
Expand Down Expand Up @@ -51,7 +51,7 @@ function consoleLogServer(opts) {
console: console,
dateFormat: "yyyy-mm-dd'T'HH:MM:sso",
ignoreUncaughtErrors: false,
defaultRoute: function defaultRoute( /** @type {RequestExt} */req, /** @type {ResponseExt} */res) {
defaultRoute: function defaultRoute(/** @type {RequestExt} */req, /** @type {ResponseExt} */res) {
var headers = _fp["default"].flow(_fp["default"].map(function (h) {
return h.split(':', 2);
}), _fp["default"].fromPairs)(opts.responseHeader);
Expand Down Expand Up @@ -126,7 +126,7 @@ function consoleLogServer(opts) {
var path = _ref.path,
host = _ref.host;
return "'".concat(path, "' -> ").concat(host);
}), _fp["default"].join(' vs. '))), _fp["default"].values, _fp["default"].join(', '))( /** @type {CLSProxy[]} */opts.proxy);
}), _fp["default"].join(' vs. '))), _fp["default"].values, _fp["default"].join(', '))(/** @type {CLSProxy[]} */opts.proxy);
if (duplicates) {
throw Error("Multiple proxies for same path(s): ".concat(duplicates));
}
Expand Down Expand Up @@ -169,7 +169,7 @@ function consoleLogServer(opts) {
server: server,
ready: ready
};
}))( /** @type {number[]} */opts.port);
}))(/** @type {number[]} */opts.port);
if (opts.ignoreUncaughtErrors) {
process.on('uncaughtException', function (err) {
cnsl.log('Unhandled error. Set ignoreUncaughtErrors to pass these through');
Expand Down
4 changes: 2 additions & 2 deletions dist/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _dateformat = _interopRequireDefault(require("dateformat"));
var _parseHeaders = _interopRequireDefault(require("parse-headers"));
var _mimeTypes = _interopRequireDefault(require("mime-types"));
var _sortedObject = _interopRequireDefault(require("sorted-object"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
* @param {RequestExt} req
* @param {ResponseExt} res
Expand Down Expand Up @@ -112,7 +112,7 @@ function logDefaultBodyError(req, res, opts) {
* @param {ResponseExt} res
* @param {CLSOptions} opts
*/
function logResponse( /** @type {RequestExt} */req, res, opts) {
function logResponse(/** @type {RequestExt} */req, res, opts) {
var ctx = createChalk(opts);
var cnsl = opts.console;
var now = (0, _dateformat["default"])(new Date(), opts.dateFormat);
Expand Down
24 changes: 12 additions & 12 deletions dist/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ var _expressHttpProxy = _interopRequireDefault(require("express-http-proxy"));
var _fp = _interopRequireDefault(require("lodash/fp"));
var _cors = _interopRequireDefault(require("cors"));
var _es6Promise = require("es6-promise");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
* @param {CLSOptions} opts
*/
var _default = exports["default"] = function _default(opts) {
var cnsl = opts.console;
var router = _express["default"].Router();
var reqCounter = 0;
router.use(function addLocals( /** @type {RequestExt} */req, res, next) {
router.use(function addLocals(/** @type {RequestExt} */req, res, next) {
req.locals || (req.locals = {});
var requestId = req.header('X-Request-ID') || req.header('X-Correlation-ID');
req.locals.id = "".concat(++reqCounter) + (requestId ? ":".concat(requestId) : '');
next();
});
if (opts.mockDate) {
// For some reason Date cannot be mocked in Node 15/16, so just override the date header when using static date
router.use(function mockDate( /** @type {RequestExt} */req, res, next) {
router.use(function mockDate(/** @type {RequestExt} */req, res, next) {
res.set('date', new Date().toUTCString());
next();
});
}
router.use(function saveRawBody( /** @type {RequestExt} */req, res, next) {
router.use(function saveRawBody(/** @type {RequestExt} */req, res, next) {
req.locals.rawBody = new _es6Promise.Promise(function (resolve) {
req.once('end', function () {
resolve(req.locals.rawBodyBuffer);
Expand All @@ -48,25 +48,25 @@ var _default = exports["default"] = function _default(opts) {
next();
});
router.use(_bodyParser["default"].json({
verify: function verify( /** @type {RequestExt} */req) {
verify: function verify(/** @type {RequestExt} */req) {
req.locals.bodyType = 'json';
}
}));
router.use(_bodyParser["default"].urlencoded({
extended: true,
verify: function verify( /** @type {RequestExt} */req) {
verify: function verify(/** @type {RequestExt} */req) {
req.locals.bodyType = 'url';
}
}));
router.use((0, _expressXmlBodyparser["default"])());
router.use(function markBodyAsXml( /** @type {RequestExt} */req, res, next) {
router.use(function markBodyAsXml(/** @type {RequestExt} */req, res, next) {
if (!req.locals.bodyType && !_fp["default"].isEmpty(req.body)) {
req.locals.bodyType = 'xml';
}
next();
});
router.use(_bodyParser["default"].text({
verify: function verify( /** @type {RequestExt} */req) {
verify: function verify(/** @type {RequestExt} */req) {
req.locals.bodyType = 'text';
}
}));
Expand All @@ -75,7 +75,7 @@ var _default = exports["default"] = function _default(opts) {
type: function type() {
return true;
},
verify: function verify( /** @type {RequestExt} */req) {
verify: function verify(/** @type {RequestExt} */req) {
req.locals.bodyType = 'raw';
}
}));
Expand All @@ -88,7 +88,7 @@ var _default = exports["default"] = function _default(opts) {
res.locals.responseCode = 400;
next();
});
router.use(function logRequestAndResponse( /** @type {RequestExt} */req, res, next) {
router.use(function logRequestAndResponse(/** @type {RequestExt} */req, res, next) {
res.on('finish', function () {
var _req$locals, _req$locals2;
if (req.locals.rawBodyBuffer === undefined || req.locals.rawBodyBuffer.length === 0) {
Expand Down Expand Up @@ -130,7 +130,7 @@ var _default = exports["default"] = function _default(opts) {
router.use(path, (0, _expressHttpProxy["default"])(host, {
https: https,
parseReqBody: false,
proxyReqPathResolver: function proxyReqPathResolver( /** @type {RequestExt} */req) {
proxyReqPathResolver: function proxyReqPathResolver(/** @type {RequestExt} */req) {
var resolvedPath = hostPath === '/' ? req.url : hostPath + req.url;
req.locals.proxyUrl = "".concat(protocolPrefix).concat(host).concat(resolvedPath);
return resolvedPath;
Expand All @@ -156,7 +156,7 @@ var _default = exports["default"] = function _default(opts) {
router.use((0, _cors["default"])());
}
if (opts.logResponse === true || !_fp["default"].isEmpty(opts.proxy) && opts.logResponse !== false) {
router.use(function captureResponse( /** @type {RequestExt} */req, res, next) {
router.use(function captureResponse(/** @type {RequestExt} */req, res, next) {
if (opts.logResponse === true) {
var oldWrite = res.write;
var oldEnd = res.end;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@types/chalk": "^2.2.0",
"@types/cors": "^2.8.10",
"@types/dateformat": "^3.0.1",
"@types/express": "^4.17.12",
Expand Down

0 comments on commit c3ec55f

Please sign in to comment.