@cocreate/crud-server 1.24.3 → 1.24.5

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.5](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.4...v1.24.5) (2023-06-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([4380523](https://github.com/CoCreate-app/CoCreate-crud-server/commit/43805236abea5333029d66dd916db8d21973140f))
7
+
8
+ ## [1.24.4](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.3...v1.24.4) (2023-06-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * check if this.config ([151ab0d](https://github.com/CoCreate-app/CoCreate-crud-server/commit/151ab0d8b912c1c7b0369f596f4ae22e19831587))
14
+
1
15
  ## [1.24.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.24.2...v1.24.3) (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.3",
3
+ "version": "1.24.5",
4
4
  "description": "CoCreate-crud-server",
5
5
  "keywords": [
6
6
  "cocreate-crud",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "homepage": "https://cocreate.app/docs/CoCreate-crud-server",
42
42
  "dependencies": {
43
- "@cocreate/config": "^1.0.4",
43
+ "@cocreate/config": "^1.0.7",
44
44
  "@cocreate/utils": "^1.21.16",
45
45
  "csvtojson": "^2.0.10",
46
46
  "json-2-csv": "^3.10.3"
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
- 'name': {
18
+ 'storage': {
19
19
  prompt: 'Enter a friendly name for the new storage: ',
20
- variable: true
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.orgaization_id) {
138
- storage = pthis.config.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, JSON.parse(storage))
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,