@cocreate/crud-server 1.23.12 → 1.23.13

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,11 @@
1
+ ## [1.23.13](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.23.12...v1.23.13) (2023-06-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * config usages ([1b2acba](https://github.com/CoCreate-app/CoCreate-crud-server/commit/1b2acba583d5f1944aa5e589ec8b166312f5379a))
7
+ * updated storage propt to Enter a JSON.stringify storage object ([3cee400](https://github.com/CoCreate-app/CoCreate-crud-server/commit/3cee400e458052db99fc18f2ddf2103a5721e500))
8
+
1
9
  ## [1.23.12](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.23.11...v1.23.12) (2023-06-11)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crud-server",
3
- "version": "1.23.12",
3
+ "version": "1.23.13",
4
4
  "description": "CoCreate-crud-server",
5
5
  "keywords": [
6
6
  "cocreate-crud",
@@ -41,6 +41,7 @@
41
41
  "homepage": "https://cocreate.app/docs/CoCreate-crud-server",
42
42
  "dependencies": {
43
43
  "@cocreate/cli": "^1.33.8",
44
+ "@cocreate/config": "^1.0.0",
44
45
  "@cocreate/utils": "^1.21.14",
45
46
  "csvtojson": "^2.0.10",
46
47
  "json-2-csv": "^3.10.3"
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const { ObjectId, searchData, sortData } = require("@cocreate/utils");
4
- const { config } = require('@cocreate/cli')
4
+ const config = require('@cocreate/config')
5
5
 
6
6
  class CoCreateCrudServer {
7
7
  constructor(wsManager, databases) {
@@ -9,20 +9,30 @@ class CoCreateCrudServer {
9
9
  this.databases = databases
10
10
  this.ObjectId = ObjectId
11
11
  this.storages = new Map();
12
- config([
13
- {
14
- key: 'organization_id',
15
- prompt: 'Enter your organization_id: ',
16
- },
17
- {
18
- key: 'storage',
19
- prompt: 'Enter your db object as json.string: ',
20
- }
21
- ])//
22
- this.init();
12
+ this.init()
23
13
  }
24
14
 
25
- init() {
15
+ async init() {
16
+ this.config = await config({
17
+ organization_id: { prompt: 'Enter your organization_id: ' },
18
+ storage: { prompt: 'Enter a JSON.stringify storage object: ' }
19
+ })
20
+
21
+ let dbUrl
22
+ if (this.config.storage) {
23
+ if (typeof this.config.storage === 'string')
24
+ this.config.storage = JSON.parse(this.config.storage)
25
+ let defaultStorage = Object.keys(this.config.storage)
26
+ dbUrl = defaultStorage[0].url[0]
27
+ }
28
+
29
+ if (!this.config.organization_id)
30
+ console.log('Could not find the organization_id')
31
+ if (!dbUrl)
32
+ console.log('Could not find a url in your storage object')
33
+ if (!dbUrl && !this.config.organization_id)
34
+ process.exit()
35
+
26
36
  if (this.wsManager) {
27
37
  this.wsManager.on('createDatabase', (socket, data) => this.crud(socket, 'createDatabase', data))
28
38
  this.wsManager.on('readDatabase', (socket, data) => this.crud(socket, 'readDatabase', data))