@brimble/models 3.7.1 → 3.7.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/dist/index.d.ts +1 -0
- package/dist/index.js +15 -1
- package/index.ts +13 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -40,3 +40,4 @@ import mongoose from "mongoose";
|
|
|
40
40
|
export declare const connectToMongo: (mongoUrl: string, config?: mongoose.ConnectOptions) => Promise<void>;
|
|
41
41
|
export declare const db: mongoose.Connection;
|
|
42
42
|
export declare const closeMongo: () => Promise<void>;
|
|
43
|
+
export declare const healthCheckMongo: () => Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.PERMISSION_TYPE = exports.DNS_TYPE = exports.CARD_TYPES = exports.SUBSCRIPTION_STATUS = exports.PROJECT_STATUS = exports.SUBSCRIPTION_PLAN_TYPE = exports.ROLES = exports.SERVER_STATUS = exports.ENVIRONMENT = exports.OAUTH_PERMISSIONS = exports.INTEGRATION_PROVIDERS = exports.INTEGRATION_TYPES = exports.GIT_TYPE = exports.Intention = exports.WebhookSetting = exports.WebhookEvent = exports.WebhookCategory = exports.DomainRenewal = exports.LoadBalancerPort = exports.Settings = exports.Framework = exports.Volume = exports.Region = exports.ComputeChange = exports.AutoScalingGroup = exports.PlanConfiguration = exports.Liscense = exports.Job = exports.DbImage = exports.Wallet = exports.Server = exports.Card = exports.Subscription = exports.Log = exports.Role = exports.MemberPermission = exports.Permission = exports.Member = exports.Team = exports.Token = exports.Env = exports.Dns = exports.Domain = exports.Integration = exports.Following = exports.ProjectConnection = exports.Preview = exports.DeletedProject = exports.Project = exports.User = void 0;
|
|
16
|
-
exports.closeMongo = exports.db = exports.connectToMongo = exports.NomadDeploymentStatus = exports.DomainRenewalStatus = exports.FrameworkApplicationType = exports.SERVER_PROTOCOL = exports.BUILD_DISABLED_BY = exports.REGION_CONTINENT = exports.LicenseStatus = exports.JobStatus = exports.DatabaseEngine = exports.ServiceType = exports.REQUEST_TYPE = void 0;
|
|
16
|
+
exports.healthCheckMongo = exports.closeMongo = exports.db = exports.connectToMongo = exports.NomadDeploymentStatus = exports.DomainRenewalStatus = exports.FrameworkApplicationType = exports.SERVER_PROTOCOL = exports.BUILD_DISABLED_BY = exports.REGION_CONTINENT = exports.LicenseStatus = exports.JobStatus = exports.DatabaseEngine = exports.ServiceType = exports.REQUEST_TYPE = void 0;
|
|
17
17
|
var user_1 = require("./user");
|
|
18
18
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return __importDefault(user_1).default; } });
|
|
19
19
|
var project_1 = require("./project");
|
|
@@ -133,3 +133,17 @@ exports.connectToMongo = connectToMongo;
|
|
|
133
133
|
exports.db = mongoose_1.default.connection;
|
|
134
134
|
const closeMongo = () => mongoose_1.default.connection.close(true);
|
|
135
135
|
exports.closeMongo = closeMongo;
|
|
136
|
+
const healthCheckMongo = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
try {
|
|
138
|
+
if (mongoose_1.default.connection.readyState !== 1) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
yield mongoose_1.default.connection.db.admin().ping();
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
utils_1.log.error(`MongoDB health check failed`, error);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
exports.healthCheckMongo = healthCheckMongo;
|
package/index.ts
CHANGED
|
@@ -135,3 +135,16 @@ export const connectToMongo = async (
|
|
|
135
135
|
export const db = mongoose.connection;
|
|
136
136
|
|
|
137
137
|
export const closeMongo = () => mongoose.connection.close(true);
|
|
138
|
+
|
|
139
|
+
export const healthCheckMongo = async (): Promise<boolean> => {
|
|
140
|
+
try {
|
|
141
|
+
if (mongoose.connection.readyState !== 1) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
await mongoose.connection.db.admin().ping();
|
|
145
|
+
return true;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
log.error(`MongoDB health check failed`, error);
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
};
|