@restroom-mw/db
Advanced tools
Comparing version 0.9.3-dccef52.7 to 0.9.3-e922873.44
@@ -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-dccef52.7+dccef52", | ||
"version": "0.9.3-e922873.44+e922873", | ||
"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": { | ||
"sequelize": "^5.21.7", | ||
"mariadb": "^2.5.4", | ||
"mysql2": "^2.2.5", | ||
"sequelize": "^6.16.0", | ||
"sqlite3": "^5.0.0" | ||
}, | ||
"gitHead": "dccef52c37657276bad1d805af336c8169ee4467" | ||
"gitHead": "e922873a3a3ab346caa1225b3c27f7a911575e50" | ||
} |
@@ -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
509
56140
4
5
+ Addedmariadb@^2.5.4
+ Addedmysql2@^2.2.5
+ Added@types/debug@4.1.12(transitive)
+ Added@types/geojson@7946.0.15(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Added@types/node@17.0.45(transitive)
+ Added@types/validator@13.12.2(transitive)
+ Addeddenque@2.1.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedinflection@1.13.4(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)
+ Addedpg-connection-string@2.7.0(transitive)
+ Addedplease-upgrade-node@3.2.0(transitive)
+ Addedretry-as-promised@7.0.4(transitive)
+ Addedsemver-compare@1.0.0(transitive)
+ Addedseq-queue@0.0.5(transitive)
+ Addedsequelize@6.37.5(transitive)
+ Addedsequelize-pool@7.1.0(transitive)
+ Addedsqlstring@2.3.3(transitive)
+ Addedwkx@0.5.0(transitive)
- Removed@types/node@22.10.2(transitive)
- Removedany-promise@1.3.0(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcls-bluebird@2.1.0(transitive)
- Removedinflection@1.12.0(transitive)
- Removedis-bluebird@1.0.2(transitive)
- Removedretry-as-promised@3.2.0(transitive)
- Removedsemver@6.3.1(transitive)
- Removedsequelize@5.22.5(transitive)
- Removedsequelize-pool@2.3.0(transitive)
- Removedshimmer@1.2.1(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedwkx@0.4.8(transitive)
Updatedsequelize@^6.16.0