joye-backend-utility 5.0.34 → 5.0.35

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/dist/database.js CHANGED
@@ -65,7 +65,7 @@ class database {
65
65
  }
66
66
  this.modelSchemaInConnection(dbConnection);
67
67
  database.connections[`${config_1.DB_KEY}`] = dbConnection;
68
- console.log('Connected to database');
68
+ console.log('Connected to database 111');
69
69
  });
70
70
  };
71
71
  this.connectionFactory = async (key, url) => {
package/dist/jwt.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const createToken: (payload: object, expiresIn: string) => Promise<any>;
2
2
  export declare const jwtVerify: (token: string) => Promise<unknown>;
3
+ export declare const decodeToken: (token: string) => any;
package/dist/jwt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jwtVerify = exports.createToken = void 0;
3
+ exports.decodeToken = exports.jwtVerify = exports.createToken = void 0;
4
4
  const jwt = require('jsonwebtoken');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
@@ -24,3 +24,17 @@ const jwtVerify = async (token) => new Promise(resolve => {
24
24
  });
25
25
  });
26
26
  exports.jwtVerify = jwtVerify;
27
+ const decodeToken = (token) => {
28
+ try {
29
+ const decodedHeader = jwt.decode(token, { complete: true });
30
+ if (!decodedHeader) {
31
+ console.log('Invalid token Error');
32
+ }
33
+ return decodedHeader;
34
+ }
35
+ catch (err) {
36
+ console.log('Token decode failed: ', err);
37
+ return null;
38
+ }
39
+ };
40
+ exports.decodeToken = decodeToken;
@@ -6,6 +6,7 @@ const Organization = new mongoose_1.Schema({
6
6
  platformKey: {
7
7
  type: String,
8
8
  required: true,
9
+ index: true,
9
10
  },
10
11
  key: {
11
12
  type: String,
@@ -74,4 +75,5 @@ const Organization = new mongoose_1.Schema({
74
75
  required: false,
75
76
  },
76
77
  });
78
+ Organization.index({ platformKey: 1, timezone: -1, inactive: -1 });
77
79
  exports.OrganizationSchema = Organization;
@@ -6,6 +6,7 @@ const User = new mongoose_1.Schema({
6
6
  organizationId: {
7
7
  type: String,
8
8
  required: true,
9
+ index: true,
9
10
  },
10
11
  employeeId: {
11
12
  type: String,
@@ -208,4 +209,13 @@ const User = new mongoose_1.Schema({
208
209
  required: false,
209
210
  },
210
211
  });
212
+ User.index({ botDetails: 1, preferredTimezone: -1 }, {
213
+ unique: false,
214
+ });
215
+ User.index({ organizationId: 1, botDetails: -1 }, {
216
+ unique: false,
217
+ });
218
+ User.index({ botDetails: 1, organizationId: -1, preferredTimezone: -1 }, {
219
+ unique: false,
220
+ });
211
221
  exports.UserSchema = User;
@@ -64,4 +64,6 @@ const UserMessageLog = new mongoose_1.Schema({
64
64
  },
65
65
  });
66
66
  UserMessageLog.index({ employeeId: 1, activityId: -1 });
67
+ UserMessageLog.index({ employeeId: 1, date: -1 });
68
+ UserMessageLog.index({ employeeId: 1, messageType: -1, status: -1, date: -1 });
67
69
  exports.UserMessageLogSchema = UserMessageLog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joye-backend-utility",
3
- "version": "5.0.34",
3
+ "version": "5.0.35",
4
4
  "description": "Joye backend utility for db functions and common functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",