@cocreate/crud-server
Advanced tools
Comparing version 1.23.1 to 1.23.2
@@ -0,1 +1,9 @@ | ||
## [1.23.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.23.1...v1.23.2) (2023-06-11) | ||
### Bug Fixes | ||
* renamed db to storage ([9b1df98](https://github.com/CoCreate-app/CoCreate-crud-server/commit/9b1df98ecae81f2c861757f51d04bf773dd77f2b)) | ||
* renamed hosts to host. the value can be a string or an array of strings ([1cfaade](https://github.com/CoCreate-app/CoCreate-crud-server/commit/1cfaadeeeccd8b899a83ed1a0c1b2d0811829b77)) | ||
## [1.23.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.23.0...v1.23.1) (2023-06-10) | ||
@@ -2,0 +10,0 @@ |
@@ -13,3 +13,3 @@ module.exports = { | ||
"src": "{{./docs/index.html}}", | ||
"hosts": [ | ||
"host": [ | ||
"*", | ||
@@ -16,0 +16,0 @@ "general.cocreate.app" |
{ | ||
"name": "@cocreate/crud-server", | ||
"version": "1.23.1", | ||
"version": "1.23.2", | ||
"description": "CoCreate-crud-server", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,3 +11,3 @@ 'use strict'; | ||
this.ObjectId = ObjectId | ||
this.dbUrls = new Map(); | ||
this.storages = new Map(); | ||
config([ | ||
@@ -19,3 +19,3 @@ { | ||
{ | ||
key: 'db', | ||
key: 'storage', | ||
prompt: 'Enter your db object as json.string: ', | ||
@@ -115,10 +115,11 @@ } | ||
let dbUrl = this.dbUrls.get(data.organization_id) | ||
if (dbUrl === false) | ||
return resolve({ dbUrl: false, error: 'database url could not be found' }) | ||
let storage = this.storages.get(data.organization_id) | ||
if (storage === false) | ||
return resolve({ storage: false, error: 'A storage or database could not be found' }) | ||
if (!dbUrl) { | ||
if (!storage) { | ||
if (data.organization_id === process.env.organization_id) { | ||
dbUrl = process.env.db | ||
this.dbUrls.set(data.organization_id, dbUrl) | ||
storage = process.env.storage | ||
if (storage) | ||
this.storages.set(data.organization_id, JSON.parse(storage)) | ||
} else { | ||
@@ -133,9 +134,9 @@ let organization = await this.readDocument({ | ||
organization = organization.document[0] | ||
if (organization && organization.databases) { | ||
dbUrl = organization.databases | ||
this.dbUrls.set(data.organization_id, dbUrl) | ||
if (organization && organization.storage) { | ||
storage = organization.storage | ||
this.storages.set(data.organization_id, storage) | ||
} else { | ||
this.dbUrls.set(data.organization_id, false) | ||
this.storages.set(data.organization_id, false) | ||
if (organization) | ||
return resolve({ dbUrl: false, error: 'database url could not be found' }) | ||
return resolve({ storage: false, error: 'database url could not be found' }) | ||
else | ||
@@ -161,3 +162,3 @@ return resolve({ organization: false, error: 'organization could not be found' }) | ||
if (data.collection === 'organizations') | ||
syncKeys = ['name', 'logo', 'databases', 'hosts', 'apis'] | ||
syncKeys = ['name', 'logo', 'databases', 'host', 'apis'] | ||
else if (data.collection === 'users') | ||
@@ -189,10 +190,10 @@ syncKeys = ['name', 'email', 'password', 'avatar'] | ||
if (!data.db || !data.db.length) { | ||
data.db = [Object.keys(dbUrl)[0]] | ||
} else if (!Array.isArray(data.db)) | ||
data.db = [data.db] | ||
if (!data.storage || !data.storage.length) { | ||
data.storage = [Object.keys(storage)[0]] | ||
} else if (!Array.isArray(data.storage)) | ||
data.storage = [data.storage] | ||
for (let i = 0; i < data.db.length; i++) { | ||
if (dbUrl && dbUrl[data.db[i]]) { | ||
let db = dbUrl[data.db[i]] | ||
for (let i = 0; i < data.storage.length; i++) { | ||
if (storage && storage[data.storage[i]]) { | ||
let db = storage[data.storage[i]] | ||
@@ -243,3 +244,3 @@ if (db.provider && this.databases[db.provider]) { | ||
if (typeof error == 'object') | ||
error['db'] = 'mongodb' | ||
error['storage'] = 'mongodb' | ||
else | ||
@@ -246,0 +247,0 @@ error = { location: 'crudServer', message: error } |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
108274
382