@monodog/backend 1.5.0 → 1.5.1

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/cli.js CHANGED
@@ -114,6 +114,7 @@ if (serve) {
114
114
  console.log(`Analyzing monorepo at root: ${rootPath}`);
115
115
  // Start the Express server and begin analysis
116
116
  (0, index_1.startServer)(rootPath, port, host);
117
+ (0, index_1.serveDashboard)(path.join(rootPath, appConfig.workspace.install_path), appConfig.dashboard.port, appConfig.dashboard.host);
117
118
  }
118
119
  else {
119
120
  console.log(`\nInitializing Configurations...`);
@@ -203,6 +204,10 @@ function createConfigFileIfMissing(rootPath) {
203
204
  "database": {
204
205
  "path": "./monodog.db" // SQLite database file path, relative to prisma schema location
205
206
  },
207
+ "dashboard": {
208
+ "host": "0.0.0.0",
209
+ "port": "3010"
210
+ },
206
211
  "server": {
207
212
  "host": "0.0.0.0", // Default host for the API server
208
213
  "port": 4000 // Default port for the API server
@@ -86,6 +86,10 @@ function createConfigFileIfMissing(rootPath) {
86
86
  "database": {
87
87
  "path": "file:./monodog.db" // SQLite database file path, relative to prisma schema location
88
88
  },
89
+ "dashboard": {
90
+ "host": "0.0.0.0",
91
+ "port": "3010"
92
+ },
89
93
  "server": {
90
94
  "host": "0.0.0.0", // Default host for the API server
91
95
  "port": 4000 // Default port for the API server
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.scanner = void 0;
7
7
  exports.startServer = startServer;
8
+ exports.serveDashboard = serveDashboard;
8
9
  const express_1 = __importDefault(require("express"));
9
10
  const cors_1 = __importDefault(require("cors"));
10
11
  const path_1 = __importDefault(require("path"));
@@ -1315,8 +1316,29 @@ function startServer(rootPath, port, host) {
1315
1316
  // packageHealth,
1316
1317
  // });
1317
1318
  }
1318
- // This is a test file to ensure the TypeScript compiler can find an input.
1319
- // export const runBackend = (name: string): string => {
1320
- // return `Backend running successfully for ${name}.`;
1321
- // };
1322
- // console.log(runBackend("MonoDog"));
1319
+ function serveDashboard(rootPath, port, host) {
1320
+ const app = (0, express_1.default)();
1321
+ // This code makes sure that any request that does not matches a static file
1322
+ // in the build folder, will just serve index.html. Client side routing is
1323
+ // going to make sure that the correct content will be loaded.
1324
+ app.use((req, res, next) => {
1325
+ if (/(.ico|.js|.css|.jpg|.png|.map)$/i.test(req.path)) {
1326
+ next();
1327
+ }
1328
+ else {
1329
+ res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
1330
+ res.header('Expires', '-1');
1331
+ res.header('Pragma', 'no-cache');
1332
+ res.sendFile('index.html', { root: path_1.default.resolve(rootPath, 'monodog-dashboard', 'dist') });
1333
+ }
1334
+ });
1335
+ const staticPath = path_1.default.resolve(rootPath, 'monodog-dashboard', 'dist');
1336
+ console.log('Serving static files from:', staticPath);
1337
+ app.use(express_1.default.static(staticPath));
1338
+ // Start the server
1339
+ const PORT = parseInt(port ? port.toString() : '3999');
1340
+ app.listen(PORT, host, () => {
1341
+ console.log(`App listening on ${host}:${port}`);
1342
+ console.log('Press Ctrl+C to quit.');
1343
+ });
1344
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monodog/backend",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Backend API server for monodog monorepo dashboard",
5
5
  "license": "MIT",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  import * as fs from 'fs';
12
12
 
13
13
  import * as path from 'path';
14
- import { startServer } from './index'; // Assume index.ts exports this function
14
+ import { startServer, serveDashboard} from './index'; // Assume index.ts exports this function
15
15
 
16
16
  import { loadConfig } from './config-loader';
17
17
 
@@ -87,6 +87,8 @@ if (serve) {
87
87
  console.log(`Analyzing monorepo at root: ${rootPath}`);
88
88
  // Start the Express server and begin analysis
89
89
  startServer(rootPath, port, host);
90
+ serveDashboard(path.join(rootPath, appConfig.workspace.install_path), appConfig.dashboard.port, appConfig.dashboard.host);
91
+
90
92
  } else {
91
93
  console.log(`\nInitializing Configurations...`);
92
94
 
@@ -192,6 +194,10 @@ const defaultContent = {
192
194
  "database": {
193
195
  "path": "./monodog.db" // SQLite database file path, relative to prisma schema location
194
196
  },
197
+ "dashboard": {
198
+ "host": "0.0.0.0",
199
+ "port": "3010"
200
+ },
195
201
  "server": {
196
202
  "host": "0.0.0.0", // Default host for the API server
197
203
  "port": 4000 // Default port for the API server
@@ -14,6 +14,10 @@ interface MonodogConfig {
14
14
  user: string;
15
15
  path: string; // Used for SQLite path or general data storage path
16
16
  };
17
+ dashboard: {
18
+ host: string;
19
+ port: number;
20
+ };
17
21
  server: {
18
22
  host: string;
19
23
  port: number;
@@ -79,6 +83,10 @@ const defaultContent = {
79
83
  "database": {
80
84
  "path": "file:./monodog.db" // SQLite database file path, relative to prisma schema location
81
85
  },
86
+ "dashboard": {
87
+ "host": "0.0.0.0",
88
+ "port": "3010"
89
+ },
82
90
  "server": {
83
91
  "host": "0.0.0.0", // Default host for the API server
84
92
  "port": 4000 // Default port for the API server
package/src/index.ts CHANGED
@@ -1514,10 +1514,31 @@ app.listen(PORT, host ,async () => {
1514
1514
 
1515
1515
  }
1516
1516
 
1517
+ export function serveDashboard(rootPath: string, port: number|string, host: string): void {
1518
+ const app = express();
1517
1519
 
1518
- // This is a test file to ensure the TypeScript compiler can find an input.
1519
- // export const runBackend = (name: string): string => {
1520
- // return `Backend running successfully for ${name}.`;
1521
- // };
1520
+ // This code makes sure that any request that does not matches a static file
1521
+ // in the build folder, will just serve index.html. Client side routing is
1522
+ // going to make sure that the correct content will be loaded.
1523
+ app.use((req, res, next) => {
1524
+ if (/(.ico|.js|.css|.jpg|.png|.map)$/i.test(req.path)) {
1525
+ next();
1526
+ } else {
1527
+ res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
1528
+ res.header('Expires', '-1');
1529
+ res.header('Pragma', 'no-cache');
1530
+ res.sendFile('index.html', { root: path.resolve(rootPath,'monodog-dashboard','dist') });
1531
+ }
1532
+ });
1533
+ const staticPath = path.resolve(rootPath,'monodog-dashboard','dist');
1534
+ console.log('Serving static files from:', staticPath);
1535
+ app.use(express.static(staticPath));
1536
+ // Start the server
1537
+ const PORT = parseInt(port ? port.toString() : '3999');
1538
+
1539
+ app.listen(PORT, host , () => {
1540
+ console.log(`App listening on ${host}:${port}`);
1541
+ console.log('Press Ctrl+C to quit.');
1542
+ });
1543
+ }
1522
1544
 
1523
- // console.log(runBackend("MonoDog"));