pms_md 1.0.3 → 1.0.5

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.
@@ -0,0 +1,261 @@
1
+ /**
2
+ * UI Router - Serves monitoring UI from package
3
+ * Provides automatic UI setup for monitoring dashboards
4
+ */
5
+
6
+ const path = require('path');
7
+ const fs = require('fs');
8
+
9
+ class UIRouter {
10
+ constructor(monitor, options = {}) {
11
+ this.monitor = monitor;
12
+ this.options = {
13
+ basePath: options.basePath || '',
14
+ enableErrorLogs: options.enableErrorLogs !== false,
15
+ appName: options.appName || monitor.config.get('app.name') || 'Node Monitor',
16
+ ...options
17
+ };
18
+
19
+ // Resolve package paths
20
+ this.packageRoot = path.resolve(__dirname, '../../');
21
+ this.viewsPath = path.join(this.packageRoot, 'examples/views');
22
+ this.publicPath = path.join(this.packageRoot, 'examples/public');
23
+
24
+ // Verify paths exist
25
+ this.verifyPaths();
26
+ }
27
+
28
+ verifyPaths() {
29
+ if (!fs.existsSync(this.viewsPath)) {
30
+ throw new Error(`Views directory not found at: ${this.viewsPath}`);
31
+ }
32
+ if (!fs.existsSync(this.publicPath)) {
33
+ throw new Error(`Public directory not found at: ${this.publicPath}`);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Setup UI routes on Express app
39
+ */
40
+ setup(app) {
41
+ // Configure EJS view engine
42
+ app.set('view engine', 'ejs');
43
+ app.set('views', this.viewsPath);
44
+
45
+ // Serve static files (CSS, JS, images)
46
+ const express = require('express');
47
+ app.use(express.static(this.publicPath));
48
+
49
+ // Register all UI routes
50
+ this.registerRoutes(app);
51
+
52
+ console.log(`✅ Node Monitor UI enabled at http://localhost:${app.get('port') || 3000}/`);
53
+ console.log(` 📊 Dashboard: /monitor/dashboard`);
54
+ console.log(` 💚 Health: /health`);
55
+ console.log(` 📈 Metrics: /monitor/metrics`);
56
+
57
+ return this;
58
+ }
59
+
60
+ /**
61
+ * Register all UI routes
62
+ */
63
+ registerRoutes(app) {
64
+ const basePath = this.options.basePath;
65
+
66
+ // Home route
67
+ app.get(`${basePath}/`, this.homeRoute.bind(this));
68
+
69
+ // Health check route
70
+ app.get(`${basePath}/health`, this.healthRoute.bind(this));
71
+
72
+ // Dashboard route
73
+ app.get(`${basePath}/monitor/dashboard`, this.dashboardRoute.bind(this));
74
+
75
+ // Status route
76
+ app.get(`${basePath}/monitor/status`, this.statusRoute.bind(this));
77
+
78
+ // Metrics route
79
+ app.get(`${basePath}/monitor/metrics`, this.metricsRoute.bind(this));
80
+
81
+ // System info route (JSON only)
82
+ app.get(`${basePath}/monitor/system`, this.systemRoute.bind(this));
83
+
84
+ // Health info route (JSON only)
85
+ app.get(`${basePath}/health/info`, this.healthInfoRoute.bind(this));
86
+
87
+ // Error logs route (if enabled)
88
+ if (this.options.enableErrorLogs) {
89
+ app.get(`${basePath}/monitor/error-logs`, this.errorLogsRoute.bind(this));
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Check if request wants JSON
95
+ */
96
+ wantsJson(req) {
97
+ const acceptsJson = req.headers.accept && req.headers.accept.includes('application/json');
98
+ const formatJson = req.query.format === 'json';
99
+ return formatJson || acceptsJson;
100
+ }
101
+
102
+ /**
103
+ * Home route handler
104
+ */
105
+ homeRoute(req, res) {
106
+ if (this.wantsJson(req)) {
107
+ return res.json({
108
+ message: `Welcome to ${this.options.appName} Monitoring`,
109
+ endpoints: {
110
+ home: '/',
111
+ health: '/health',
112
+ healthInfo: '/health/info',
113
+ dashboard: '/monitor/dashboard',
114
+ status: '/monitor/status',
115
+ system: '/monitor/system',
116
+ metrics: '/monitor/metrics',
117
+ errorLogs: this.options.enableErrorLogs ? '/monitor/error-logs' : null
118
+ }
119
+ });
120
+ }
121
+
122
+ res.render('home', {
123
+ title: 'Home',
124
+ headerIcon: '🏠',
125
+ headerTitle: this.options.appName,
126
+ subtitle: null,
127
+ currentPage: 'home',
128
+ includeCharts: false,
129
+ pageScript: null
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Health check route handler
135
+ */
136
+ healthRoute(req, res) {
137
+ if (this.wantsJson(req)) {
138
+ return this.monitor.healthCheckEndpoint()(req, res);
139
+ }
140
+
141
+ res.render('health', {
142
+ title: 'Health Check',
143
+ headerIcon: '💚',
144
+ headerTitle: 'Health Check',
145
+ subtitle: 'System health status and monitoring',
146
+ currentPage: 'health',
147
+ includeCharts: false,
148
+ pageScript: 'health.js'
149
+ });
150
+ }
151
+
152
+ /**
153
+ * Dashboard route handler
154
+ */
155
+ dashboardRoute(req, res) {
156
+ if (this.wantsJson(req)) {
157
+ return this.monitor.dashboardEndpoint()(req, res);
158
+ }
159
+
160
+ res.render('dashboard', {
161
+ title: 'Dashboard',
162
+ headerIcon: '📊',
163
+ headerTitle: 'Monitoring Dashboard',
164
+ subtitle: 'Real-time application monitoring and analytics',
165
+ currentPage: 'dashboard',
166
+ includeCharts: false,
167
+ pageScript: 'dashboard.js'
168
+ });
169
+ }
170
+
171
+ /**
172
+ * Status route handler
173
+ */
174
+ statusRoute(req, res) {
175
+ if (this.wantsJson(req)) {
176
+ return res.json(this.monitor.getStatus());
177
+ }
178
+
179
+ res.render('status', {
180
+ title: 'API Status',
181
+ headerIcon: '📋',
182
+ headerTitle: 'API Status',
183
+ subtitle: 'Real-time application status and metrics',
184
+ currentPage: 'status',
185
+ includeCharts: false,
186
+ pageScript: null
187
+ });
188
+ }
189
+
190
+ /**
191
+ * Metrics route handler
192
+ */
193
+ metricsRoute(req, res) {
194
+ if (this.wantsJson(req)) {
195
+ return res.json({
196
+ timestamp: new Date().toISOString(),
197
+ history: this.monitor.getMetricsHistory()
198
+ });
199
+ }
200
+
201
+ res.render('metrics', {
202
+ title: 'Metrics',
203
+ headerIcon: '📈',
204
+ headerTitle: 'System Metrics',
205
+ subtitle: 'Performance monitoring and analytics',
206
+ currentPage: 'metrics',
207
+ includeCharts: true,
208
+ pageScript: 'metrics.js'
209
+ });
210
+ }
211
+
212
+ /**
213
+ * System info route handler (JSON only)
214
+ */
215
+ systemRoute(req, res) {
216
+ res.json(this.monitor.getSystemInfo());
217
+ }
218
+
219
+ /**
220
+ * Health info route handler (JSON only)
221
+ */
222
+ healthInfoRoute(req, res) {
223
+ this.monitor.healthInfoEndpoint()(req, res);
224
+ }
225
+
226
+ /**
227
+ * Error logs route handler
228
+ */
229
+ errorLogsRoute(req, res) {
230
+ if (this.wantsJson(req)) {
231
+ return res.json({
232
+ message: 'Error logs endpoint',
233
+ logs: []
234
+ });
235
+ }
236
+
237
+ res.render('error-logs', {
238
+ title: 'Error Logs',
239
+ headerIcon: '🚨',
240
+ headerTitle: 'Error Logs',
241
+ subtitle: 'Application error tracking',
242
+ currentPage: 'error-logs',
243
+ includeCharts: false,
244
+ pageScript: 'error-logs.js'
245
+ });
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Factory function to setup UI
251
+ */
252
+ function setup(app, monitor, options = {}) {
253
+ const router = new UIRouter(monitor, options);
254
+ return router.setup(app);
255
+ }
256
+
257
+ module.exports = {
258
+ UIRouter,
259
+ setup
260
+ };
261
+
@@ -351,7 +351,7 @@
351
351
  <div class="timestamp" id="lastUpdate"></div>
352
352
 
353
353
  <div class="footer">
354
- <p>Node Monitor v1.0.0 | Built with ❤️ By Manish Desai</p>
354
+ <p>Node Monitor v1.0.4 | Built with ❤️ By Manish Desai</p>
355
355
  </div>
356
356
  </div>
357
357
 
package/package.json CHANGED
@@ -1,123 +1,131 @@
1
- {
2
- "name": "pms_md",
3
- "version": "1.0.3",
4
- "description": "Comprehensive monitoring solution for Node.js applications with error tracking, health checks, multi-database support (MongoDB, PostgreSQL, MySQL, MSSQL, SQLite, Redis, Cassandra, Elasticsearch, DynamoDB, Neo4j, CouchDB), and multi-channel notifications",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "jest",
8
- "start": "node node-monitor/examples/express-app.js"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://gitlab.com/manish-proses/pms_md.git"
13
- },
14
- "keywords": [
15
- "proses",
16
- "monitoring",
17
- "health-check",
18
- "error-tracking",
19
- "notifications",
20
- "alerts",
21
- "nodejs",
22
- "express",
23
- "logging",
24
- "winston",
25
- "error-handler",
26
- "health-monitoring",
27
- "system-monitoring",
28
- "email-notifications",
29
- "slack-notifications"
30
- ],
31
- "author": "Manish Desai",
32
- "license": "ISC",
33
- "bugs": {
34
- "url": "https://gitlab.com/manish-proses/pms_md/issues"
35
- },
36
- "homepage": "https://gitlab.com/manish-proses/pms_md#readme",
37
- "dependencies": {
38
- "winston": "^3.11.0",
39
- "winston-daily-rotate-file": "^4.7.1",
40
- "nodemailer": "^6.9.7",
41
- "@slack/webhook": "^7.0.2",
42
- "axios": "^1.6.2",
43
- "node-cron": "^3.0.3"
44
- },
45
- "peerDependencies": {
46
- "express": "^4.18.0 || ^5.0.0",
47
- "mongoose": "^7.0.0 || ^8.0.0",
48
- "pg": "^8.0.0",
49
- "mysql2": "^2.0.0 || ^3.0.0",
50
- "mariadb": "^3.0.0",
51
- "mssql": "^9.0.0 || ^10.0.0",
52
- "tedious": "^15.0.0 || ^16.0.0",
53
- "sqlite3": "^5.0.0",
54
- "better-sqlite3": "^8.0.0 || ^9.0.0",
55
- "sequelize": "^6.0.0",
56
- "ioredis": "^5.0.0",
57
- "nano": "^10.0.0",
58
- "cassandra-driver": "^4.0.0",
59
- "@elastic/elasticsearch": "^8.0.0",
60
- "@aws-sdk/client-dynamodb": "^3.0.0",
61
- "aws-sdk": "^2.0.0",
62
- "neo4j-driver": "^5.0.0"
63
- },
64
- "peerDependenciesMeta": {
65
- "express": {
66
- "optional": true
67
- },
68
- "mongoose": {
69
- "optional": true
70
- },
71
- "pg": {
72
- "optional": true
73
- },
74
- "mysql2": {
75
- "optional": true
76
- },
77
- "mariadb": {
78
- "optional": true
79
- },
80
- "mssql": {
81
- "optional": true
82
- },
83
- "tedious": {
84
- "optional": true
85
- },
86
- "sqlite3": {
87
- "optional": true
88
- },
89
- "better-sqlite3": {
90
- "optional": true
91
- },
92
- "sequelize": {
93
- "optional": true
94
- },
95
- "ioredis": {
96
- "optional": true
97
- },
98
- "nano": {
99
- "optional": true
100
- },
101
- "cassandra-driver": {
102
- "optional": true
103
- },
104
- "@elastic/elasticsearch": {
105
- "optional": true
106
- },
107
- "@aws-sdk/client-dynamodb": {
108
- "optional": true
109
- },
110
- "aws-sdk": {
111
- "optional": true
112
- },
113
- "neo4j-driver": {
114
- "optional": true
115
- }
116
- },
117
- "devDependencies": {
118
- "jest": "^29.7.0"
119
- },
120
- "engines": {
121
- "node": ">=14.0.0"
122
- }
123
- }
1
+ {
2
+ "name": "pms_md",
3
+ "version": "1.0.5",
4
+ "description": "Comprehensive monitoring solution for Node.js applications with error tracking, health checks, multi-database support (MongoDB, PostgreSQL, MySQL, MSSQL, SQLite, Redis, Cassandra, Elasticsearch, DynamoDB, Neo4j, CouchDB), and multi-channel notifications",
5
+ "main": "index.js",
6
+ "files": [
7
+ "index.js",
8
+ "node-monitor/",
9
+ "README.md",
10
+ ".gitignore"
11
+ ],
12
+ "scripts": {
13
+ "test": "jest",
14
+ "start": "node node-monitor/examples/express-app.js"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://gitlab.com/manish-proses/pms_md.git"
19
+ },
20
+ "keywords": [
21
+ "proses",
22
+ "monitoring",
23
+ "health-check",
24
+ "error-tracking",
25
+ "notifications",
26
+ "alerts",
27
+ "nodejs",
28
+ "express",
29
+ "logging",
30
+ "winston",
31
+ "error-handler",
32
+ "health-monitoring",
33
+ "system-monitoring",
34
+ "email-notifications",
35
+ "slack-notifications"
36
+ ],
37
+ "author": "Manish Desai",
38
+ "license": "ISC",
39
+ "bugs": {
40
+ "url": "https://gitlab.com/manish-proses/pms_md/issues"
41
+ },
42
+ "homepage": "https://gitlab.com/manish-proses/pms_md#readme",
43
+ "dependencies": {
44
+ "@slack/webhook": "^7.0.2",
45
+ "axios": "^1.6.2",
46
+ "dotenv": "^17.2.3",
47
+ "ejs": "^3.1.10",
48
+ "node-cron": "^3.0.3",
49
+ "nodemailer": "^6.9.7",
50
+ "winston": "^3.11.0",
51
+ "winston-daily-rotate-file": "^4.7.1"
52
+ },
53
+ "peerDependencies": {
54
+ "@aws-sdk/client-dynamodb": "^3.0.0",
55
+ "@elastic/elasticsearch": "^8.0.0",
56
+ "aws-sdk": "^2.0.0",
57
+ "better-sqlite3": "^8.0.0 || ^9.0.0",
58
+ "cassandra-driver": "^4.0.0",
59
+ "express": "^5.2.1",
60
+ "ioredis": "^5.0.0",
61
+ "mariadb": "^3.0.0",
62
+ "mongoose": "^7.0.0 || ^8.0.0",
63
+ "mssql": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0",
64
+ "mysql2": "^2.0.0 || ^3.0.0",
65
+ "nano": "^10.0.0",
66
+ "neo4j-driver": "^5.0.0",
67
+ "pg": "^8.0.0",
68
+ "sequelize": "^6.0.0",
69
+ "sqlite3": "^5.0.0",
70
+ "tedious": "^14.0.0 || ^15.0.0 || ^16.0.0"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "express": {
74
+ "optional": true
75
+ },
76
+ "mongoose": {
77
+ "optional": true
78
+ },
79
+ "pg": {
80
+ "optional": true
81
+ },
82
+ "mysql2": {
83
+ "optional": true
84
+ },
85
+ "mariadb": {
86
+ "optional": true
87
+ },
88
+ "mssql": {
89
+ "optional": true
90
+ },
91
+ "tedious": {
92
+ "optional": true
93
+ },
94
+ "sqlite3": {
95
+ "optional": true
96
+ },
97
+ "better-sqlite3": {
98
+ "optional": true
99
+ },
100
+ "sequelize": {
101
+ "optional": true
102
+ },
103
+ "ioredis": {
104
+ "optional": true
105
+ },
106
+ "nano": {
107
+ "optional": true
108
+ },
109
+ "cassandra-driver": {
110
+ "optional": true
111
+ },
112
+ "@elastic/elasticsearch": {
113
+ "optional": true
114
+ },
115
+ "@aws-sdk/client-dynamodb": {
116
+ "optional": true
117
+ },
118
+ "aws-sdk": {
119
+ "optional": true
120
+ },
121
+ "neo4j-driver": {
122
+ "optional": true
123
+ }
124
+ },
125
+ "devDependencies": {
126
+ "jest": "^29.7.0"
127
+ },
128
+ "engines": {
129
+ "node": ">=14.0.0"
130
+ }
131
+ }