@heliyos/heliyos-api-core 1.0.29 → 1.0.30
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/app.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/mongoose.d.ts +5 -1
- package/dist/mongoose.js +18 -3
- package/package.json +1 -1
package/dist/app.js
CHANGED
|
@@ -64,7 +64,7 @@ const coreApp = (app, routes, options) => __awaiter(void 0, void 0, void 0, func
|
|
|
64
64
|
server.close(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
65
|
logger_1.logger.info("HTTP server closed");
|
|
66
66
|
// Disconnect from MongoDB
|
|
67
|
-
yield mongoose_1.
|
|
67
|
+
yield mongoose_1.mongoInstance.disconnect();
|
|
68
68
|
// Exit process
|
|
69
69
|
process.exit(0);
|
|
70
70
|
}));
|
package/dist/index.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export type { BaseError, CustomAxiosError } from "./@types/globals/customError";
|
|
|
18
18
|
export { HttpError } from "./@types/globals/customError";
|
|
19
19
|
export type { ICoreAppOptions } from "./@types/globals/middleware";
|
|
20
20
|
export type { RolesPermissionsType, ResourcePolicyActionsType, } from "./static/authPolicyFile";
|
|
21
|
-
export { Schema, Document, Model, FilterQuery, UpdateQuery, Pagination, Types, } from "./mongoose";
|
|
21
|
+
export { Schema, Document, Model, FilterQuery, UpdateQuery, Pagination, Types, mongooseConnection, mongoInstance, } from "./mongoose";
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Types = exports.Model = exports.Document = exports.Schema = exports.HttpError = exports.getSecretsManagerSecret = exports.resendSendEmail = exports.pusherTriggerBatch = exports.pusherTrigger = exports.pusher = exports.emailTemplates = exports.getEmailTemplate = exports.allowedOrigin = exports.logger = exports.SQSUtil = exports.createRedisClient = exports.authorizeUser = exports.authPolicy = exports.loadAppEnv = exports.joiObject = exports.validate = exports.axios = exports.coreApp = exports.authentication = void 0;
|
|
26
|
+
exports.mongoInstance = exports.mongooseConnection = exports.Types = exports.Model = exports.Document = exports.Schema = exports.HttpError = exports.getSecretsManagerSecret = exports.resendSendEmail = exports.pusherTriggerBatch = exports.pusherTrigger = exports.pusher = exports.emailTemplates = exports.getEmailTemplate = exports.allowedOrigin = exports.logger = exports.SQSUtil = exports.createRedisClient = exports.authorizeUser = exports.authPolicy = exports.loadAppEnv = exports.joiObject = exports.validate = exports.axios = exports.coreApp = exports.authentication = void 0;
|
|
27
27
|
const dotenv = __importStar(require("dotenv"));
|
|
28
28
|
dotenv.config();
|
|
29
29
|
// Core exports
|
|
@@ -70,3 +70,5 @@ Object.defineProperty(exports, "Schema", { enumerable: true, get: function () {
|
|
|
70
70
|
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return mongoose_1.Document; } });
|
|
71
71
|
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return mongoose_1.Model; } });
|
|
72
72
|
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return mongoose_1.Types; } });
|
|
73
|
+
Object.defineProperty(exports, "mongooseConnection", { enumerable: true, get: function () { return mongoose_1.mongooseConnection; } });
|
|
74
|
+
Object.defineProperty(exports, "mongoInstance", { enumerable: true, get: function () { return mongoose_1.mongoInstance; } });
|
package/dist/mongoose.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
1
2
|
export * from "mongoose";
|
|
2
3
|
export declare class MongoConnectionManager {
|
|
3
4
|
private static instance;
|
|
@@ -9,8 +10,11 @@ export declare class MongoConnectionManager {
|
|
|
9
10
|
static getInstance(): MongoConnectionManager;
|
|
10
11
|
initialize(): Promise<void>;
|
|
11
12
|
disconnect(): Promise<void>;
|
|
13
|
+
getConnection(): mongoose.Connection;
|
|
14
|
+
logConnectionStatus(): void;
|
|
12
15
|
}
|
|
13
|
-
export declare const
|
|
16
|
+
export declare const mongoInstance: MongoConnectionManager;
|
|
17
|
+
export declare const mongooseConnection: mongoose.Connection;
|
|
14
18
|
export declare function initializeDatabase(): Promise<void>;
|
|
15
19
|
export interface Pagination<T> {
|
|
16
20
|
data: T[];
|
package/dist/mongoose.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.mongooseConnection = exports.mongoInstance = exports.MongoConnectionManager = void 0;
|
|
30
30
|
exports.initializeDatabase = initializeDatabase;
|
|
31
31
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
32
32
|
const logger_1 = require("./logger");
|
|
@@ -116,14 +116,29 @@ class MongoConnectionManager {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
+
getConnection() {
|
|
120
|
+
return mongoose_1.default.connection;
|
|
121
|
+
}
|
|
122
|
+
logConnectionStatus() {
|
|
123
|
+
logger_1.logger.info("MongoDB Connection Status:", {
|
|
124
|
+
readyState: mongoose_1.default.connection.readyState,
|
|
125
|
+
models: Object.keys(mongoose_1.default.connection.models),
|
|
126
|
+
collections: Object.keys(mongoose_1.default.connection.collections),
|
|
127
|
+
host: mongoose_1.default.connection.host,
|
|
128
|
+
port: mongoose_1.default.connection.port,
|
|
129
|
+
name: mongoose_1.default.connection.name,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
119
132
|
}
|
|
120
133
|
exports.MongoConnectionManager = MongoConnectionManager;
|
|
121
134
|
MongoConnectionManager.connectionCount = 0; // Add connection counter
|
|
122
135
|
// Export singleton instance
|
|
123
|
-
exports.
|
|
136
|
+
exports.mongoInstance = MongoConnectionManager.getInstance();
|
|
137
|
+
// Export mongoose connection singleton
|
|
138
|
+
exports.mongooseConnection = exports.mongoInstance.getConnection();
|
|
124
139
|
// Export connection initialization function
|
|
125
140
|
function initializeDatabase() {
|
|
126
|
-
return exports.
|
|
141
|
+
return exports.mongoInstance.initialize();
|
|
127
142
|
}
|
|
128
143
|
mongoose_1.default.Query.prototype.paginate = function () {
|
|
129
144
|
return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
|