@brimble/models 1.4.75 → 1.4.76

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.
@@ -1,3 +1,3 @@
1
1
  yarn run v1.22.19
2
2
  $ tsc -p .
3
- Done in 1.81s.
3
+ Done in 1.80s.
package/dist/index.d.ts CHANGED
@@ -15,6 +15,6 @@ export { default as Tenancy } from "./tenancy";
15
15
  export { IUser, IGit, IProject, IFollowing, IIntegration, IEnv, IServer, ITenancy, IDomain, IToken, IMember, ITeam, IInstalledIntegration, ILog, ISubscriptionPlan, ICard } from "./types";
16
16
  export { GIT_TYPE, INTEGRATION_TYPES, INTEGRATION_PROVIDERS, OAUTH_PERMISSIONS, ENVIRONMENT, SERVER_STATUS, ROLES, PROJECT_STATUS, SUBSCRIPTION_STATUS, CARD_TYPES } from "./enum";
17
17
  import mongoose from "mongoose";
18
- export declare const connectToMongo: (mongoUrl: string, retryCount?: number, config?: mongoose.ConnectOptions) => Promise<void>;
18
+ export declare const connectToMongo: (mongoUrl: string, config?: mongoose.ConnectOptions) => Promise<void>;
19
19
  export declare const db: mongoose.Connection;
20
20
  export declare const closeMongo: () => Promise<void>;
package/dist/index.js CHANGED
@@ -55,19 +55,13 @@ Object.defineProperty(exports, "CARD_TYPES", { enumerable: true, get: function (
55
55
  const mongoose_1 = __importDefault(require("mongoose"));
56
56
  const utils_1 = require("@brimble/utils");
57
57
  // Connection to Mongo
58
- const connectToMongo = (mongoUrl, retryCount, config) => __awaiter(void 0, void 0, void 0, function* () {
59
- const options = Object.assign({ useNewUrlParser: true, useUnifiedTopology: true, poolSize: 10, socketTimeoutMS: 30000 }, config);
58
+ const connectToMongo = (mongoUrl, config) => __awaiter(void 0, void 0, void 0, function* () {
59
+ const options = Object.assign({ useNewUrlParser: true, useUnifiedTopology: true, poolSize: 10, socketTimeoutMS: 30000, reconnectTries: 10, reconnectInterval: 3000 }, config);
60
60
  mongoose_1.default.set("useFindAndModify", false);
61
61
  mongoose_1.default.set("useCreateIndex", true);
62
62
  // connect to mongo
63
63
  mongoose_1.default.connect(mongoUrl, options).catch((err) => {
64
- if (retryCount && retryCount > 0) {
65
- setTimeout(() => {
66
- (0, exports.connectToMongo)(mongoUrl, retryCount - 1);
67
- }, 5000);
68
- }
69
- else
70
- process.exit(1);
64
+ utils_1.log.error(`Unable to connect to mongo db, ${err}`);
71
65
  });
72
66
  // listen for connection
73
67
  mongoose_1.default.connection.on("connected", () => {
package/index.ts CHANGED
@@ -50,14 +50,15 @@ import { log } from "@brimble/utils";
50
50
  // Connection to Mongo
51
51
  export const connectToMongo = async (
52
52
  mongoUrl: string,
53
- retryCount?: number,
54
53
  config?: mongoose.ConnectOptions
55
54
  ): Promise<void> => {
56
- const options = {
55
+ const options: mongoose.ConnectOptions = {
57
56
  useNewUrlParser: true,
58
57
  useUnifiedTopology: true,
59
58
  poolSize: 10,
60
59
  socketTimeoutMS: 30000,
60
+ reconnectTries: 10,
61
+ reconnectInterval: 3000,
61
62
  ...config
62
63
  };
63
64
  mongoose.set("useFindAndModify", false);
@@ -65,11 +66,7 @@ export const connectToMongo = async (
65
66
 
66
67
  // connect to mongo
67
68
  mongoose.connect(mongoUrl, options).catch((err) => {
68
- if (retryCount && retryCount > 0) {
69
- setTimeout(() => {
70
- connectToMongo(mongoUrl, retryCount - 1);
71
- }, 5000);
72
- } else process.exit(1);
69
+ log.error(`Unable to connect to mongo db, ${err}`)
73
70
  });
74
71
 
75
72
  // listen for connection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brimble/models",
3
- "version": "1.4.75",
3
+ "version": "1.4.76",
4
4
  "description": "Brimble models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,5 +21,5 @@
21
21
  "ts-node": "^8.10.2",
22
22
  "typescript": "^4.9.4"
23
23
  },
24
- "gitHead": "7a6f022e4782116612ce06e48d227b3ca06034a2"
24
+ "gitHead": "087bfd2e5628be17b9cf6d6c03239105217a4419"
25
25
  }