@dnax/core 0.19.0 → 0.19.2

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/app/index.ts CHANGED
@@ -25,16 +25,16 @@ async function runApp(config?: configRunApp, clb?: Function) {
25
25
  await loadCfg(); // Load Config
26
26
 
27
27
  const PORT = Cfg.server?.port || process.env?.PORT || 4000;
28
- const PORT_SOCKET = Cfg.server?.socket?.port || 9000;
28
+ /* const PORT_SOCKET = Cfg.server?.socket?.port || 9000;
29
29
 
30
30
  // available port Socket
31
31
  await findPort.isAvailable(PORT_SOCKET).then(async (available: boolean) => {
32
32
  if (!available) {
33
33
  console.error(`⚠️ Socket Port ${PORT_SOCKET} is not available`);
34
34
  console.log("");
35
- process.exit();
35
+ process.exit(1);
36
36
  }
37
- });
37
+ }); */
38
38
 
39
39
  // available port Server
40
40
  await findPort.isAvailable(PORT).then(async (available: boolean) => {
@@ -114,6 +114,6 @@ async function runApp(config?: configRunApp, clb?: Function) {
114
114
  });
115
115
  }
116
116
 
117
- process.on("exit", async () => {});
117
+ //process.on("exit", async () => {});
118
118
 
119
119
  export { runApp };
@@ -24,6 +24,10 @@ async function connectToMongo(t: Tenant) {
24
24
  t.database.isConnected = false;
25
25
  });
26
26
 
27
+ client.on("error", (err) => {
28
+ console.error(` Tenant ${t.id} : `, err?.message);
29
+ });
30
+
27
31
  client.on("close", () => {
28
32
  t.database.isConnected = false;
29
33
  connectToMongo(t);
package/lib/collection.ts CHANGED
@@ -71,6 +71,7 @@ async function syncCollectionDatabase() {
71
71
 
72
72
  if (collections?.length) {
73
73
  for await (let c of collections) {
74
+ // boucle sur les collections
74
75
  //console.log(c?.slug,c.init)
75
76
  if (c?.init && typeof c?.init == "function") {
76
77
  await c?.init({
@@ -92,7 +93,7 @@ async function syncCollectionDatabase() {
92
93
  }
93
94
 
94
95
  // suppression auto Removes des indexes
95
- if (c?.autoRemoveIndexes?.length && c?.autoRemoveIndexes) {
96
+ if (c?.autoRemoveIndexes?.length) {
96
97
  for await (let index of c?.autoRemoveIndexes || []) {
97
98
  await t.database?.db
98
99
  ?.collection(c.slug)
@@ -147,6 +148,18 @@ async function syncCollectionDatabase() {
147
148
  }
148
149
  });
149
150
 
151
+ // suppression d'index
152
+ c?.fields?.map((f) => {
153
+ if (f?.unique === false) {
154
+ t.database.db
155
+ ?.collection(c.slug)
156
+ .dropIndex(f.name)
157
+ .catch((err) => {
158
+ //console.error(err);
159
+ });
160
+ }
161
+ });
162
+
150
163
  // 3- Creation des indexes par indexes array
151
164
  for await (let index of c?.indexes || []) {
152
165
  let indexHasAlready = allIndexes?.find((el) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.19.0",
3
+ "version": "0.19.2",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -251,7 +251,7 @@ export type Collection = {
251
251
  deleteMany?: (ctx: ctxApi) => object | null | undefined;
252
252
  find?: (ctx: ctxApi) => Array<object> | null | undefined;
253
253
  findOne?: (ctx: ctxApi) => object;
254
- count: (ctx: ctxApi) => number;
254
+ count?: (ctx: ctxApi) => number;
255
255
  };
256
256
  cache?: {
257
257
  ttl?: string;
@@ -397,13 +397,6 @@ export type Config = {
397
397
  allowMethods?: string[];
398
398
  allowHeaders?: string[];
399
399
  };
400
- socket?: {
401
- /**
402
- * Socket port
403
- * Default port is 9000
404
- */
405
- port?: Number;
406
- };
407
400
 
408
401
  /**
409
402
  * Port to run the server
package/utils/index.ts CHANGED
@@ -330,6 +330,8 @@ const password = {
330
330
  verify: verifyHashPassword,
331
331
  };
332
332
 
333
+
334
+
333
335
  export {
334
336
  dotJson,
335
337
  uuid,
package/utils/os.ts ADDED
@@ -0,0 +1 @@
1
+ function Os() {}
package/utils/test.js DELETED
@@ -1,23 +0,0 @@
1
- function isDate(date) {
2
- const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
3
- let isDate_ = !isNaN(Date.parse(date)) && dateRegex.test(date);
4
- return isDate_;
5
- }
6
-
7
- function transformAllDate(data) {
8
- try {
9
- if (typeof data == "object" && data !== null && data !== undefined) {
10
- mapKeys(data, (key, value) => {
11
- if (typeof value == "string" && value && isDate(value)) {
12
- data[key] = new Date(value);
13
- } else {
14
- return transformAllDate(data[key]);
15
- }
16
- });
17
- }
18
- //console.log(data);
19
- return data;
20
- } catch (error) {
21
- throw error;
22
- }
23
- }