@restroom-mw/db
Advanced tools
Comparing version 0.9.3-1bc602d.8 to 0.9.3-2b8285e.31
@@ -28,4 +28,3 @@ "use strict"; | ||
catch (e) { | ||
throw new Error(`[DATABASE] | ||
Error in JSON format "${o}"`); | ||
throw new Error(`[DATABASE] Error in JSON format "${o}"`); | ||
} | ||
@@ -44,2 +43,16 @@ }; | ||
const { zencode, keys, data } = params; | ||
keysContent = | ||
typeof keys === "undefined" | ||
? {} | ||
: keys && typeof keys === "object" | ||
? keys | ||
: parse(keys); | ||
dataContent = | ||
typeof data === "undefined" | ||
? {} | ||
: data && typeof data === "object" | ||
? data | ||
: parse(data); | ||
content = Object.assign(Object.assign({}, dataContent), keysContent); | ||
contentKeys = Object.keys(content); | ||
if (zencode.match(ACTIONS.GET_URI_KEYS)) { | ||
@@ -53,16 +66,2 @@ dbUriKeys = zencode.paramsOf(ACTIONS.GET_URI_KEYS); | ||
const dbAllRecordData = zencode.paramsOf(ACTIONS.GET_RECORD); | ||
keysContent = | ||
typeof keys === "undefined" | ||
? {} | ||
: keys && typeof keys === "object" | ||
? keys | ||
: parse(keys); | ||
dataContent = | ||
typeof data === "undefined" | ||
? {} | ||
: data && typeof data === "object" | ||
? data | ||
: parse(data); | ||
content = Object.assign(Object.assign({}, dataContent), keysContent); | ||
contentKeys = Object.keys(content); | ||
//create object(s) with the FOUR values of each GET_RECORD | ||
@@ -221,5 +220,7 @@ const dbQueries = []; | ||
// check that all endpoints (urlKeys) are properties in either data or keys | ||
if (contentKeys.includes(key[keyName]) === false) { | ||
throw new Error(`[DATABASE] | ||
Endpoint "${key[keyName]}" has not been defined in keys or data.`); | ||
if (contentKeys) { | ||
if (contentKeys.includes(key[keyName]) === false) { | ||
throw new Error(`[DATABASE] | ||
Endpoint "${key[keyName]}" has not been defined in keys or data.`); | ||
} | ||
} | ||
@@ -240,3 +241,3 @@ }); | ||
throw new Error(`[HTTP] | ||
Boolean values are not permitted. Response JSON has property "${key}" with a boolean value. | ||
Boolean values are not permitted. Response JSON has property "${key}" with a boolean value. | ||
Please use, for example, 0 and 1`); | ||
@@ -243,0 +244,0 @@ } |
{ | ||
"name": "@restroom-mw/db", | ||
"version": "0.9.3-1bc602d.8+1bc602d", | ||
"version": "0.9.3-2b8285e.31+2b8285e", | ||
"description": "Database utilities middleware for Restroom", | ||
@@ -25,2 +25,4 @@ "author": "Puria Nafisi Azizi <puria@dyne.org>", | ||
"build": "tsc -b tsconfig.json", | ||
"unlinks": "yarn unlink", | ||
"links": "yarn link", | ||
"test": "nyc ava" | ||
@@ -35,6 +37,8 @@ }, | ||
"dependencies": { | ||
"mariadb": "^2.5.4", | ||
"mysql2": "^2.2.5", | ||
"sequelize": "^5.21.7", | ||
"sqlite3": "^5.0.0" | ||
}, | ||
"gitHead": "1bc602d083e2a99c76ecf3b4dec64c95f06f515f" | ||
"gitHead": "2b8285e3885d1a0df4d11909f59dab7ff514f669" | ||
} |
@@ -22,4 +22,3 @@ import { DataTypes, Model, Sequelize } from "sequelize"; | ||
} catch (e) { | ||
throw new Error(`[DATABASE] | ||
Error in JSON format "${o}"`); | ||
throw new Error(`[DATABASE] Error in JSON format "${o}"`); | ||
} | ||
@@ -63,2 +62,16 @@ }; | ||
const { zencode, keys, data } = params; | ||
keysContent = | ||
typeof keys === "undefined" | ||
? {} | ||
: keys && typeof keys === "object" | ||
? keys | ||
: parse(keys); | ||
dataContent = | ||
typeof data === "undefined" | ||
? {} | ||
: data && typeof data === "object" | ||
? data | ||
: parse(data); | ||
content = { ...dataContent, ...keysContent }; | ||
contentKeys = Object.keys(content); | ||
@@ -75,16 +88,3 @@ if (zencode.match(ACTIONS.GET_URI_KEYS)) { | ||
const dbAllRecordData: string[] = zencode.paramsOf(ACTIONS.GET_RECORD); | ||
keysContent = | ||
typeof keys === "undefined" | ||
? {} | ||
: keys && typeof keys === "object" | ||
? keys | ||
: parse(keys); | ||
dataContent = | ||
typeof data === "undefined" | ||
? {} | ||
: data && typeof data === "object" | ||
? data | ||
: parse(data); | ||
content = { ...dataContent, ...keysContent }; | ||
contentKeys = Object.keys(content); | ||
//create object(s) with the FOUR values of each GET_RECORD | ||
@@ -257,5 +257,7 @@ const dbQueries: QueryGetRecord[] = []; | ||
// check that all endpoints (urlKeys) are properties in either data or keys | ||
if (contentKeys.includes(key[keyName]) === false) { | ||
throw new Error(`[DATABASE] | ||
Endpoint "${key[keyName]}" has not been defined in keys or data.`); | ||
if (contentKeys) { | ||
if (contentKeys.includes(key[keyName]) === false) { | ||
throw new Error(`[DATABASE] | ||
Endpoint "${key[keyName]}" has not been defined in keys or data.`); | ||
} | ||
} | ||
@@ -276,3 +278,3 @@ }); | ||
throw new Error(`[HTTP] | ||
Boolean values are not permitted. Response JSON has property "${key}" with a boolean value. | ||
Boolean values are not permitted. Response JSON has property "${key}" with a boolean value. | ||
Please use, for example, 0 and 1`); | ||
@@ -279,0 +281,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
59036
509
4
+ Addedmariadb@^2.5.4
+ Addedmysql2@^2.2.5
+ Added@types/geojson@7946.0.15(transitive)
+ Added@types/node@17.0.45(transitive)
+ Addeddenque@2.1.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedlong@4.0.05.2.3(transitive)
+ Addedlru-cache@7.18.3(transitive)
+ Addedmariadb@2.5.6(transitive)
+ Addedmysql2@2.3.3(transitive)
+ Addednamed-placeholders@1.1.3(transitive)
+ Addedplease-upgrade-node@3.2.0(transitive)
+ Addedsemver-compare@1.0.0(transitive)
+ Addedseq-queue@0.0.5(transitive)
+ Addedsqlstring@2.3.3(transitive)
- Removed@types/node@22.10.2(transitive)
- Removedundici-types@6.20.0(transitive)