@cocreate/crud-server 1.24.1 → 1.24.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.24.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.2...v1.24.3) (2023-06-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * process.env.storage replaced with this.config.storage ([547d9db](https://github.com/CoCreate-app/CoCreate-crud-server/commit/547d9db0a41d0a77b6032245292b32e38b85ace0))
7
+
8
+ ## [1.24.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.1...v1.24.2) (2023-06-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * dbUrl ([b8b8f7d](https://github.com/CoCreate-app/CoCreate-crud-server/commit/b8b8f7d1f91e6d7c7053379c1a27def02647f84c))
14
+
1
15
  ## [1.24.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.0...v1.24.1) (2023-06-15)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crud-server",
3
- "version": "1.24.1",
3
+ "version": "1.24.3",
4
4
  "description": "CoCreate-crud-server",
5
5
  "keywords": [
6
6
  "cocreate-crud",
package/src/index.js CHANGED
@@ -32,7 +32,7 @@ class CoCreateCrudServer {
32
32
  if (typeof this.config.storage === 'string')
33
33
  this.config.storage = JSON.parse(this.config.storage)
34
34
  let defaultStorage = Object.keys(this.config.storage)
35
- dbUrl = defaultStorage[0].url[0]
35
+ dbUrl = this.config.storage[defaultStorage[0]].url
36
36
  }
37
37
 
38
38
  if (!this.config.organization_id)
@@ -134,16 +134,16 @@ class CoCreateCrudServer {
134
134
  return resolve({ storage: false, error: 'A storage or database could not be found' })
135
135
 
136
136
  if (!storage) {
137
- if (data.organization_id === process.env.organization_id) {
138
- storage = process.env.storage
137
+ if (data.organization_id === this.config.orgaization_id) {
138
+ storage = pthis.config.storage
139
139
  if (storage)
140
140
  this.storages.set(data.organization_id, JSON.parse(storage))
141
141
  } else {
142
142
  let organization = await this.readDocument({
143
- database: process.env.organization_id,
143
+ database: this.config.organization_id,
144
144
  collection: 'organizations',
145
145
  document: [{ _id: data.organization_id }],
146
- organization_id: process.env.organization_id
146
+ organization_id: this.config.organization_id
147
147
  })
148
148
  if (organization && organization.document && organization.document[0])
149
149
  organization = organization.document[0]
@@ -171,7 +171,7 @@ class CoCreateCrudServer {
171
171
  if (!data.database)
172
172
  data['database'] = data.organization_id
173
173
 
174
- if (action === 'updateDocument' && data.organization_id !== process.env.organization_id) {
174
+ if (action === 'updateDocument' && data.organization_id !== this.config.organization_id) {
175
175
  let syncKeys
176
176
  if (data.collection === 'organizations')
177
177
  syncKeys = ['name', 'logo', 'databases', 'host', 'apis']
@@ -180,10 +180,10 @@ class CoCreateCrudServer {
180
180
 
181
181
  if (syncKeys && syncKeys.length) {
182
182
  let platformUpdate = {
183
- database: process.env.organization_id,
183
+ database: this.config.organization_id,
184
184
  collection: data.collection,
185
185
  document: [{}],
186
- organization_id: process.env.organization_id
186
+ organization_id: this.config.organization_id
187
187
  }
188
188
 
189
189
  let document = data.document[0] || data.document
@@ -225,10 +225,10 @@ class CoCreateCrudServer {
225
225
 
226
226
  delete data.dbUrl
227
227
  if (socket) {
228
- if (data.organization_id === process.env.organization_id && socket.config.organization_id !== data.organization_id) {
228
+ if (data.organization_id === this.config.organization_id && socket.config.organization_id !== data.organization_id) {
229
229
  this.wsManager.broadcast({
230
230
  config: {
231
- organization_id: process.env.organization_id,
231
+ organization_id: this.config.organization_id,
232
232
  }
233
233
  }, action, { ...data });
234
234
  data.organization_id = socket.config.organization_id