@monodog/backend 1.1.22 → 1.2.0
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/README.md +72 -0
- package/dist/cli.js +2 -2
- package/dist/index.js +20 -21
- package/package.json +1 -1
- package/prisma/monolite.db-journal +0 -0
- package/src/cli.ts +2 -2
- package/src/index.ts +20 -20
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Monodog: Monorepo Analytics and Health API
|
|
2
|
+
|
|
3
|
+
## 🎯 Overview
|
|
4
|
+
|
|
5
|
+
This is the backend service designed to provide comprehensive analytics, health monitoring, and dependency tracking for a large **JavaScript/TypeScript monorepo**.
|
|
6
|
+
It leverages specialized **@monodog** tools and a database layer (via **Prisma**) to efficiently manage, persist, and expose data about all packages within the repository.
|
|
7
|
+
|
|
8
|
+
This service is typically run locally or on a central server to power a dedicated frontend dashboard.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🛠 Technology Stack
|
|
13
|
+
|
|
14
|
+
| Component | Technology | Description |
|
|
15
|
+
|------------|-------------|--------------|
|
|
16
|
+
| **Language** | TypeScript & Node.js | Core language for runtime execution. |
|
|
17
|
+
| **Framework** | Express.js | Handles all API routing and middleware. |
|
|
18
|
+
| **ORM** | Prisma | Database layer for managing package and health status records. |
|
|
19
|
+
| **Scanning** | @monodog/monorepo-scanner | Core logic for file system scanning and package metadata extraction. |
|
|
20
|
+
| **VCS** | GitService | Used to fetch and analyze commit history per package path. |
|
|
21
|
+
| **Networking** | cors, body-parser | Essential middleware for API connectivity. |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## ⚙️ Prerequisites
|
|
26
|
+
|
|
27
|
+
You must have the following installed to run the service:
|
|
28
|
+
|
|
29
|
+
- **Node.js:** Version 18+ recommended
|
|
30
|
+
- **Package Manager:** `pnpm` or `npm` (use the one your monorepo uses)
|
|
31
|
+
- **Database:** A running instance of a database supported by Prisma (e.g., PostgreSQL, SQLite, MySQL)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🚀 Getting Started
|
|
36
|
+
|
|
37
|
+
### Installation
|
|
38
|
+
|
|
39
|
+
Clone the repository and install the dependencies:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Clone the repository
|
|
43
|
+
git clone https://github.com/lakinmindfire/MonoDog.git
|
|
44
|
+
cd packages/backend
|
|
45
|
+
|
|
46
|
+
# Install dependencies
|
|
47
|
+
pnpm install
|
|
48
|
+
|
|
49
|
+
# Database Setup (Prisma)
|
|
50
|
+
|
|
51
|
+
The application requires the database schema to be set up using **Prisma Migrate**.
|
|
52
|
+
|
|
53
|
+
pnpm prisma generate
|
|
54
|
+
|
|
55
|
+
pnpm prisma migrate dev
|
|
56
|
+
|
|
57
|
+
### Run backend server on port 4000 (default)
|
|
58
|
+
|
|
59
|
+
pnpm monodog-cli --serve --root .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Key API Endpoints
|
|
63
|
+
|
|
64
|
+
| Method | Route | Purpose | Persistence |
|
|
65
|
+
|--------|--------|----------|-------------|
|
|
66
|
+
| **GET** | `/api/packages` | Retrieve all package metadata from the database. | Cached / Persistent |
|
|
67
|
+
| **GET** | `/api/packages/refresh` | Trigger a full file scan of the monorepo and update/sync the database. | Triggers write |
|
|
68
|
+
| **GET** | `/api/packages/:name` | Get detailed info, reports, and CI status for a package. | Cached / Persistent |
|
|
69
|
+
| **GET** | `/api/health/packages` | Fetch the latest health metrics (score, build status) for all packages. | Persistent |
|
|
70
|
+
| **GET** | `/api/health/refresh` | Recalculate all package health metrics (tests, lint, security) and update the database. | Triggers write |
|
|
71
|
+
| **GET** | `/api/commits/:packagePath` | Fetch Git commit history for a specific package directory. | Generated runtime |
|
|
72
|
+
| **GET** | `/api/config/files` | Scan the monorepo for essential configuration files (e.g., `tsconfig`, `.eslintrc`). | Generated runtime |
|
package/dist/cli.js
CHANGED
|
@@ -155,9 +155,9 @@ function copyPackageToWorkspace(rootDir) {
|
|
|
155
155
|
// Post-copy instructions
|
|
156
156
|
console.log("\n*** IMPORTANT NEXT STEPS (MANDATORY) ***");
|
|
157
157
|
console.log("1.Migrate Database:");
|
|
158
|
-
console.log(` - pnpm
|
|
158
|
+
console.log(` - pnpm prisma migrate --schema ./node_modules/@monodog/backend/prisma/schema.prisma`);
|
|
159
159
|
console.log("2. Generate Client:");
|
|
160
|
-
console.log(` - pnpm exec prisma generate --schema ./node_modules
|
|
160
|
+
console.log(` - pnpm exec prisma generate --schema ./node_modules/@monodog/backend/prisma/schema.prisma`);
|
|
161
161
|
console.log("3. Run Backend app server with dashboard setup");
|
|
162
162
|
console.log(` - pnpm monodog-cli @monodog/dashboard --serve --root .`);
|
|
163
163
|
}
|
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ function startServer(rootPath) {
|
|
|
115
115
|
const packages = (0, helpers_1.scanMonorepo)(rootDir);
|
|
116
116
|
console.log('packages -->', packages.length);
|
|
117
117
|
for (const pkg of packages) {
|
|
118
|
-
(0, helpers_2.storePackage)(pkg);
|
|
118
|
+
await (0, helpers_2.storePackage)(pkg);
|
|
119
119
|
}
|
|
120
120
|
res.json(packages);
|
|
121
121
|
}
|
|
@@ -229,25 +229,24 @@ function startServer(rootPath) {
|
|
|
229
229
|
}
|
|
230
230
|
});
|
|
231
231
|
// Get dependency graph
|
|
232
|
-
app.get('/api/graph', async (_req, res) => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
232
|
+
// app.get('/api/graph', async (_req, res) => {
|
|
233
|
+
// try {
|
|
234
|
+
// const packages = scanMonorepo(process.cwd());
|
|
235
|
+
// const graph = generateDependencyGraph(packages);
|
|
236
|
+
// const circularDeps = findCircularDependencies(packages);
|
|
237
|
+
// res.json({
|
|
238
|
+
// ...graph,
|
|
239
|
+
// circularDependencies: circularDeps,
|
|
240
|
+
// metadata: {
|
|
241
|
+
// totalNodes: graph.nodes.length,
|
|
242
|
+
// totalEdges: graph.edges.length,
|
|
243
|
+
// circularDependencies: circularDeps.length,
|
|
244
|
+
// },
|
|
245
|
+
// });
|
|
246
|
+
// } catch (error) {
|
|
247
|
+
// res.status(500).json({ error: 'Failed to generate dependency graph' });
|
|
248
|
+
// }
|
|
249
|
+
// });
|
|
251
250
|
// Get monorepo statistics
|
|
252
251
|
app.get('/api/stats', async (_req, res) => {
|
|
253
252
|
try {
|
|
@@ -1106,7 +1105,7 @@ function startServer(rootPath) {
|
|
|
1106
1105
|
console.log(` - GET /api/packages`);
|
|
1107
1106
|
console.log(` - GET /api/packages/:name`);
|
|
1108
1107
|
console.log(` - GET /api/commits/:packagePath`);
|
|
1109
|
-
console.log(` - GET /api/graph`);
|
|
1108
|
+
// console.log(` - GET /api/graph`);
|
|
1110
1109
|
console.log(` - GET /api/stats`);
|
|
1111
1110
|
console.log(` - GET /api/ci/status`);
|
|
1112
1111
|
console.log(` - POST /api/ci/trigger`);
|
package/package.json
CHANGED
|
Binary file
|
package/src/cli.ts
CHANGED
|
@@ -138,9 +138,9 @@ function copyPackageToWorkspace(rootDir: string): void {
|
|
|
138
138
|
// Post-copy instructions
|
|
139
139
|
console.log("\n*** IMPORTANT NEXT STEPS (MANDATORY) ***");
|
|
140
140
|
console.log("1.Migrate Database:");
|
|
141
|
-
console.log(` - pnpm
|
|
141
|
+
console.log(` - pnpm prisma migrate --schema ./node_modules/@monodog/backend/prisma/schema.prisma`);
|
|
142
142
|
console.log("2. Generate Client:");
|
|
143
|
-
console.log(` - pnpm exec prisma generate --schema ./node_modules
|
|
143
|
+
console.log(` - pnpm exec prisma generate --schema ./node_modules/@monodog/backend/prisma/schema.prisma`);
|
|
144
144
|
console.log("3. Run Backend app server with dashboard setup");
|
|
145
145
|
console.log(` - pnpm monodog-cli @monodog/dashboard --serve --root .`);
|
|
146
146
|
|
package/src/index.ts
CHANGED
|
@@ -145,7 +145,7 @@ app.get('/api/packages/refresh', async (_req, res) => {
|
|
|
145
145
|
const packages = scanMonorepo(rootDir);
|
|
146
146
|
console.log('packages -->', packages.length);
|
|
147
147
|
for (const pkg of packages) {
|
|
148
|
-
storePackage(pkg)
|
|
148
|
+
await storePackage(pkg)
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
res.json(packages);
|
|
@@ -275,25 +275,25 @@ app.get('/api/commits/:packagePath', async (_req, res) => {
|
|
|
275
275
|
});
|
|
276
276
|
|
|
277
277
|
// Get dependency graph
|
|
278
|
-
app.get('/api/graph', async (_req, res) => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
// app.get('/api/graph', async (_req, res) => {
|
|
279
|
+
// try {
|
|
280
|
+
// const packages = scanMonorepo(process.cwd());
|
|
281
|
+
// const graph = generateDependencyGraph(packages);
|
|
282
|
+
// const circularDeps = findCircularDependencies(packages);
|
|
283
283
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
});
|
|
284
|
+
// res.json({
|
|
285
|
+
// ...graph,
|
|
286
|
+
// circularDependencies: circularDeps,
|
|
287
|
+
// metadata: {
|
|
288
|
+
// totalNodes: graph.nodes.length,
|
|
289
|
+
// totalEdges: graph.edges.length,
|
|
290
|
+
// circularDependencies: circularDeps.length,
|
|
291
|
+
// },
|
|
292
|
+
// });
|
|
293
|
+
// } catch (error) {
|
|
294
|
+
// res.status(500).json({ error: 'Failed to generate dependency graph' });
|
|
295
|
+
// }
|
|
296
|
+
// });
|
|
297
297
|
|
|
298
298
|
// Get monorepo statistics
|
|
299
299
|
app.get('/api/stats', async (_req, res) => {
|
|
@@ -1279,7 +1279,7 @@ app.listen(PORT, () => {
|
|
|
1279
1279
|
console.log(` - GET /api/packages`);
|
|
1280
1280
|
console.log(` - GET /api/packages/:name`);
|
|
1281
1281
|
console.log(` - GET /api/commits/:packagePath`);
|
|
1282
|
-
console.log(` - GET /api/graph`);
|
|
1282
|
+
// console.log(` - GET /api/graph`);
|
|
1283
1283
|
console.log(` - GET /api/stats`);
|
|
1284
1284
|
console.log(` - GET /api/ci/status`);
|
|
1285
1285
|
console.log(` - POST /api/ci/trigger`);
|