@cocreate/crud-server 1.24.3 → 1.24.4
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 +7 -0
- package/package.json +1 -1
- package/src/index.js +22 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.24.4](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.3...v1.24.4) (2023-06-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* check if this.config ([151ab0d](https://github.com/CoCreate-app/CoCreate-crud-server/commit/151ab0d8b912c1c7b0369f596f4ae22e19831587))
|
|
7
|
+
|
|
1
8
|
## [1.24.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.2...v1.24.3) (2023-06-15)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -15,9 +15,9 @@ class CoCreateCrudServer {
|
|
|
15
15
|
async init() {
|
|
16
16
|
this.config = await Config({
|
|
17
17
|
'organization_id': { prompt: 'Enter your organization_id: ' },
|
|
18
|
-
'
|
|
18
|
+
'storage': {
|
|
19
19
|
prompt: 'Enter a friendly name for the new storage: ',
|
|
20
|
-
variable:
|
|
20
|
+
variable: 'name'
|
|
21
21
|
},
|
|
22
22
|
'storage.{{name}}.provider': {
|
|
23
23
|
prompt: 'Enter the storage provider, ex mongodb: '
|
|
@@ -126,18 +126,34 @@ class CoCreateCrudServer {
|
|
|
126
126
|
async crud(socket, action, data) {
|
|
127
127
|
return new Promise(async (resolve) => {
|
|
128
128
|
try {
|
|
129
|
-
if (!data.organization_id)
|
|
129
|
+
if (!data.organization_id || !this.config)
|
|
130
130
|
return resolve()
|
|
131
|
+
if (!this.config)
|
|
132
|
+
this.config = await Config({
|
|
133
|
+
'organization_id': { prompt: 'Enter your organization_id: ' },
|
|
134
|
+
'storage': {
|
|
135
|
+
prompt: 'Enter a friendly name for the new storage: ',
|
|
136
|
+
variable: 'name'
|
|
137
|
+
},
|
|
138
|
+
'storage.{{name}}.provider': {
|
|
139
|
+
prompt: 'Enter the storage provider, ex mongodb: '
|
|
140
|
+
},
|
|
141
|
+
'storage.{{name}}.url': {
|
|
142
|
+
prompt: 'Enter the storage providers url: '
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
|
|
131
147
|
|
|
132
148
|
let storage = this.storages.get(data.organization_id)
|
|
133
149
|
if (storage === false)
|
|
134
150
|
return resolve({ storage: false, error: 'A storage or database could not be found' })
|
|
135
151
|
|
|
136
152
|
if (!storage) {
|
|
137
|
-
if (data.organization_id === this.config.
|
|
138
|
-
storage =
|
|
153
|
+
if (data.organization_id === this.config.organization_id) {
|
|
154
|
+
storage = this.config.storage
|
|
139
155
|
if (storage)
|
|
140
|
-
this.storages.set(data.organization_id,
|
|
156
|
+
this.storages.set(data.organization_id, storage)
|
|
141
157
|
} else {
|
|
142
158
|
let organization = await this.readDocument({
|
|
143
159
|
database: this.config.organization_id,
|