diff --git a/api-doc.json b/api-doc.json index db28fb9..74c9322 100644 --- a/api-doc.json +++ b/api-doc.json @@ -749,6 +749,74 @@ "deprecated": false } }, + "/public/reports/embed/report": { + "get": { + "tags": [ + "Public/Reports" + ], + "summary": "Retrieve embed token", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + } + }, + "deprecated": false + }, + "post": { + "tags": [ + "Public/Reports" + ], + "summary": "Set embedded parameters", + "description": "", + "parameters": [ + { + "name": "obj", + "in": "body", + "description": "Report Parameters", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "name" + }, + "value": { + "type": "string", + "example": "value" + }, + "type": { + "type": "string", + "example": "type" + } + }, + "required": [ + "name", + "value", + "type" + ] + } + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + } + }, + "deprecated": false + } + }, "/public/reports/mls/image/{mls}/{overview}/{width}/{height}": { "get": { "tags": [ diff --git a/app.js b/app.js index a452304..5003685 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,7 @@ var config = require("./config"); const pathToSwaggerUi = require("swagger-ui-dist").absolutePath(); const fs = require("fs"); const packageJson = require("./package.json"); -var corsMiddleware = require("restify-cors-middleware"); +var corsMiddleware = require("restify-cors-middleware2"); const documentationOutputFile = require("path").join(__dirname, "./api-doc.json"); // CORS FOR RESTIFY diff --git a/helpers/weather.js b/helpers/weather.js index 2d2851a..47fb3e5 100644 --- a/helpers/weather.js +++ b/helpers/weather.js @@ -1,8 +1,15 @@ const sqlServer = require("./sqlServer"); -const common = require("./common"); const fetch = require("node-fetch"); -var xml2js = require("xml2js"); -var parser = new xml2js.Parser(); +const { XMLParser } = require("fast-xml-parser"); +const options = { + ignoreAttributes: false, // Ignore the XML attributes + numberParseOptions: { + leadingZeros: false, + }, + attributeNamePrefix: "", // Default is an underscore. Set to null to disable it + attributesGroupName: "$", // XML node attributes group name prefix +}; +const parser = new XMLParser(options); module.exports = { getRadarImages: function (fromDate, toDate, callback) { @@ -39,9 +46,7 @@ module.exports = { return response.text(); }) .then((responseText) => { - parser.parseString(responseText, function (err, result) { - callback(result); - }); + callback(parser.parse(responseText)); }) .catch((error) => { console.error(error); diff --git a/package-lock.json b/package-lock.json index 13608ea..3219470 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "canvas": "^2.11.0", "cors": "^2.8.5", "dotenv": "^16.1.4", + "fast-xml-parser": "^4.2.7", "geojson": "^0.5.0", "got": "^11.8.6", "moment": "^2.29.4", @@ -22,13 +23,12 @@ "nodemailer": "^6.9.1", "pg": "^8.10.0", "restify": "^11.1.0", - "restify-cors-middleware": "^1.1.1", + "restify-cors-middleware2": "^2.2.1", "swagger-autogen": "^2.23.1", - "swagger-ui-dist": "^4.18.2", - "xml2js": "^0.5.0" + "swagger-ui-dist": "^4.18.2" }, "devDependencies": { - "nodemon": "^2.0.22" + "nodemon": "^3.0.1" } }, "node_modules/@azure/abort-controller": { @@ -861,6 +861,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "peer": true, + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, "node_modules/axios-ntlm": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/axios-ntlm/-/axios-ntlm-1.4.1.tgz", @@ -1596,6 +1606,27 @@ "node": ">=6" } }, + "node_modules/fast-xml-parser": { + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.7.tgz", + "integrity": "sha512-J8r6BriSLO1uj2miOk1NW0YVm8AGOOu3Si2HQp/cSmo6EA4m3fcwu2WKjJ4RK9wMLBtg69y1kS8baDiQBR41Ig==", + "funding": [ + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + }, + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2877,9 +2908,9 @@ } }, "node_modules/nodemon": { - "version": "2.0.22", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", - "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", + "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", "dev": true, "dependencies": { "chokidar": "^3.5.2", @@ -2887,8 +2918,8 @@ "ignore-by-default": "^1.0.1", "minimatch": "^3.1.2", "pstree.remy": "^1.1.8", - "semver": "^5.7.1", - "simple-update-notifier": "^1.0.7", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", "supports-color": "^5.5.0", "touch": "^3.1.0", "undefsafe": "^2.0.5" @@ -2897,7 +2928,7 @@ "nodemon": "bin/nodemon.js" }, "engines": { - "node": ">=8.10.0" + "node": ">=10" }, "funding": { "type": "opencollective", @@ -2919,6 +2950,21 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/nodemon/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/nopt": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", @@ -3465,15 +3511,15 @@ "dtrace-provider": "~0.8" } }, - "node_modules/restify-cors-middleware": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/restify-cors-middleware/-/restify-cors-middleware-1.1.1.tgz", - "integrity": "sha512-yh/TnX0/T8cejOFRK8iinwDSexPOJ6RmlM8gwj2/Fk8XlGew4ldi0Db0444KT6S6BqlD61709xbxEh0oKlbkOg==", + "node_modules/restify-cors-middleware2": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/restify-cors-middleware2/-/restify-cors-middleware2-2.2.1.tgz", + "integrity": "sha512-j7Hvufd5dv699OeVuSk6YUH/HMga6a4A1zriGc6En/SDE3kzeDvQF82a3LMcVa+GaUfXxQa+TpVP8LRtcdIJWg==", "dependencies": { "assert-plus": "^1.0.0" }, "peerDependencies": { - "restify": "2.6.x - 7.x.x" + "restify": "2.6.x - 11.x.x" } }, "node_modules/restify-errors": { @@ -3842,24 +3888,30 @@ } }, "node_modules/simple-update-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", - "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", "dev": true, "dependencies": { - "semver": "~7.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8.10.0" + "node": ">=10" } }, "node_modules/simple-update-notifier/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, "bin": { "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/soap": { @@ -4158,6 +4210,11 @@ "node": ">=4" } }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -4488,26 +4545,6 @@ "node": ">=0.4.0" } }, - "node_modules/xml2js": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", - "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", - "dependencies": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", - "engines": { - "node": ">=4.0" - } - }, "node_modules/xpath": { "version": "0.0.32", "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.32.tgz", diff --git a/package.json b/package.json index c3f9546..049de0f 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "doc-gen": "node swagger.js" }, "devDependencies": { - "nodemon": "^2.0.22" + "nodemon": "^3.0.1" }, "dependencies": { "@mapbox/node-pre-gyp": "^1.0.10", @@ -22,6 +22,7 @@ "canvas": "^2.11.0", "cors": "^2.8.5", "dotenv": "^16.1.4", + "fast-xml-parser": "^4.2.7", "geojson": "^0.5.0", "got": "^11.8.6", "moment": "^2.29.4", @@ -31,9 +32,8 @@ "nodemailer": "^6.9.1", "pg": "^8.10.0", "restify": "^11.1.0", - "restify-cors-middleware": "^1.1.1", + "restify-cors-middleware2": "^2.2.1", "swagger-autogen": "^2.23.1", - "swagger-ui-dist": "^4.18.2", - "xml2js": "^0.5.0" + "swagger-ui-dist": "^4.18.2" } }