@cocreate/crud-server
Advanced tools
Comparing version 1.28.2 to 1.28.3
@@ -0,1 +1,10 @@ | ||
## [1.28.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.28.2...v1.28.3) (2023-09-17) | ||
### Bug Fixes | ||
* merge send and crud functions to send ([9cee69e](https://github.com/CoCreate-app/CoCreate-crud-server/commit/9cee69ef3dfb5ccf922ca7f3cab5259bf4181b12)) | ||
* nested for loop [i] to [j] ([90c2523](https://github.com/CoCreate-app/CoCreate-crud-server/commit/90c2523f1e315d59c89e3a69427e3c6b25bae071)) | ||
* socket referenced in the data object. data.socket ([8023572](https://github.com/CoCreate-app/CoCreate-crud-server/commit/8023572223f4e91906333be7bf2fb022a7daa8f6)) | ||
## [1.28.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.28.1...v1.28.2) (2023-08-21) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "@cocreate/crud-server", | ||
"version": "1.28.2", | ||
"version": "1.28.3", | ||
"description": "CoCreate-crud-server", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"author": "CoCreate LLC", | ||
"license": "SSPL-1.0", | ||
"license": "AGPL-3.0", | ||
"bugs": { | ||
@@ -40,0 +40,0 @@ "url": "https://github.com/CoCreate-app/CoCreate-crud-server/issues" |
@@ -52,3 +52,4 @@ 'use strict'; | ||
const action = method[i] + '.' + type[j]; | ||
this.wsManager.on(action, (socket, data) => this.crud(socket, data)) | ||
this.wsManager.on(action, (data) => | ||
this.send(data)) | ||
} | ||
@@ -60,7 +61,2 @@ } | ||
async send(data) { | ||
data = await this.crud('', data) | ||
return data | ||
} | ||
async crud(socket, data) { | ||
return new Promise(async (resolve) => { | ||
@@ -126,5 +122,3 @@ try { | ||
let action = data.method.replace(/\.([a-z])/g, (_, match) => match.toUpperCase()); | ||
// TODO: support stats from multiple dbs | ||
if (data.array || data.method === 'databaseStats') { | ||
if (data.array) { | ||
if (!data.database) | ||
@@ -156,3 +150,3 @@ data['database'] = data.organization_id | ||
this[action](platformUpdate) | ||
this.send(platformUpdate) | ||
} | ||
@@ -176,17 +170,19 @@ | ||
storage.url = [storage.url] | ||
for (let i = 0; i < storage.url.length; i++) { | ||
for (let j = 0; j < storage.url.length; j++) { | ||
data['storageName'] = data.storage[i] | ||
data['storageUrl'] = storage.url[i] | ||
data = await this.databases[storage.provider][action](data) | ||
data['storageUrl'] = storage.url[j] | ||
data = await this.databases[storage.provider].send(data) | ||
} | ||
if (data.filter) { | ||
if (data.$filter) { | ||
if (!data.type) | ||
data.type = data.method.split('.').pop() | ||
if (data.filter.sort && data.filter.sort.length) | ||
data[data.type] = sortData(array, data.filter.sort) | ||
if (data.filter.index && data.filter.limit) { | ||
data[data.type] = data[data.type].slice(data.filter.index, data.filter.limit) | ||
} | ||
data.filter.count = data[data.type].length | ||
if (data.$filter.sort && data.$filter.sort.length) | ||
data[data.type] = sortData(array, data.$filter.sort) | ||
if (data.$filter.index && data.$filter.limit) | ||
data[data.type] = data[data.type].slice(data.$filter.index, data.$filter.limit) | ||
data.$filter.count = data[data.type].length | ||
} | ||
@@ -201,4 +197,4 @@ | ||
if (socket) { | ||
if (data.organization_id === this.config.organization_id && socket.config.organization_id !== data.organization_id) { | ||
if (data.socket) { | ||
if (data.organization_id === this.config.organization_id && data.socket.config.organization_id !== data.organization_id) { | ||
this.wsManager.broadcast({ | ||
@@ -209,6 +205,6 @@ config: { | ||
}, { ...data }); | ||
data.organization_id = socket.config.organization_id | ||
data.organization_id = data.socket.config.organization_id | ||
} | ||
this.wsManager.broadcast(socket, data); | ||
this.wsManager.broadcast(data); | ||
process.emit('changed-object', data) | ||
@@ -220,5 +216,5 @@ resolve() | ||
} catch (error) { | ||
if (socket) { | ||
if (data.socket) { | ||
this.errorHandler(data, error) | ||
this.wsManager.send(socket, data); | ||
this.wsManager.send(data); | ||
resolve() | ||
@@ -225,0 +221,0 @@ } else { |
Sorry, the diff of this file is not supported yet
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
116054
2
70
243