cerber-core 1.0.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/.cerber-example/BIBLE.md +132 -0
- package/.cerber-example/CERBER_LAW.md +200 -0
- package/.cerber-example/connections/contracts/booking-to-pricing.json +44 -0
- package/.cerber-example/connections/contracts/pricing-to-booking.json +37 -0
- package/.cerber-example/modules/booking-calendar/MODULE.md +225 -0
- package/.cerber-example/modules/booking-calendar/contract.json +106 -0
- package/.cerber-example/modules/booking-calendar/dependencies.json +8 -0
- package/.cerber-example/modules/pricing-engine/MODULE.md +160 -0
- package/.cerber-example/modules/pricing-engine/contract.json +64 -0
- package/.cerber-example/modules/pricing-engine/dependencies.json +8 -0
- package/CHANGELOG.md +68 -0
- package/LICENSE +21 -0
- package/README.md +1379 -0
- package/bin/cerber +105 -0
- package/bin/cerber-focus +31 -0
- package/bin/cerber-guardian +90 -0
- package/bin/cerber-health +113 -0
- package/bin/cerber-morning +19 -0
- package/bin/cerber-repair +21 -0
- package/dist/cerber/index.d.ts +47 -0
- package/dist/cerber/index.d.ts.map +1 -0
- package/dist/cerber/index.js +154 -0
- package/dist/cerber/index.js.map +1 -0
- package/dist/guardian/index.d.ts +70 -0
- package/dist/guardian/index.d.ts.map +1 -0
- package/dist/guardian/index.js +271 -0
- package/dist/guardian/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/examples/backend-schema.ts +72 -0
- package/examples/frontend-schema.ts +67 -0
- package/examples/health-checks.ts +196 -0
- package/examples/solo-integration/README.md +457 -0
- package/examples/solo-integration/package.json +47 -0
- package/examples/team-integration/README.md +347 -0
- package/examples/team-integration/package.json +23 -0
- package/package.json +104 -0
- package/solo/README.md +258 -0
- package/solo/config/performance-budget.json +53 -0
- package/solo/config/solo-contract.json +71 -0
- package/solo/lib/feature-flags.ts +177 -0
- package/solo/scripts/cerber-auto-repair.js +260 -0
- package/solo/scripts/cerber-daily-check.js +282 -0
- package/solo/scripts/cerber-dashboard.js +191 -0
- package/solo/scripts/cerber-deps-health.js +247 -0
- package/solo/scripts/cerber-docs-sync.js +304 -0
- package/solo/scripts/cerber-flags-check.js +229 -0
- package/solo/scripts/cerber-performance-budget.js +271 -0
- package/solo/scripts/cerber-rollback.js +229 -0
- package/solo/scripts/cerber-snapshot.js +319 -0
- package/team/README.md +327 -0
- package/team/config/team-contract.json +27 -0
- package/team/lib/module-system.ts +157 -0
- package/team/scripts/cerber-add-module.sh +195 -0
- package/team/scripts/cerber-connections-check.sh +186 -0
- package/team/scripts/cerber-focus.sh +170 -0
- package/team/scripts/cerber-module-check.sh +165 -0
- package/team/scripts/cerber-team-morning.sh +210 -0
- package/team/templates/BIBLE_TEMPLATE.md +52 -0
- package/team/templates/CONNECTION_TEMPLATE.json +20 -0
- package/team/templates/MODULE_TEMPLATE.md +60 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Health Checks for Cerber
|
|
3
|
+
* Shows typical runtime checks for web applications
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { makeIssue } from '../src/cerber';
|
|
9
|
+
import type { CerberCheck } from '../src/types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Check if required environment variables are set
|
|
13
|
+
*/
|
|
14
|
+
export const checkEnvVariables: CerberCheck = async (ctx) => {
|
|
15
|
+
const required = [
|
|
16
|
+
'DATABASE_URL',
|
|
17
|
+
'JWT_SECRET',
|
|
18
|
+
'API_PORT',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const missing = required.filter(key => !process.env[key]);
|
|
22
|
+
|
|
23
|
+
if (missing.length > 0) {
|
|
24
|
+
return [makeIssue({
|
|
25
|
+
code: 'ENV_MISSING',
|
|
26
|
+
component: 'Environment',
|
|
27
|
+
severity: 'critical',
|
|
28
|
+
message: `Missing required environment variables: ${missing.join(', ')}`,
|
|
29
|
+
fix: 'Set missing variables in .env file or environment',
|
|
30
|
+
})];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return [];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check database connectivity
|
|
38
|
+
*/
|
|
39
|
+
export const checkDatabase: CerberCheck = async (ctx) => {
|
|
40
|
+
const startTime = Date.now();
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
// Example: ping database
|
|
44
|
+
// await db.ping();
|
|
45
|
+
|
|
46
|
+
const duration = Date.now() - startTime;
|
|
47
|
+
|
|
48
|
+
if (duration > 1000) {
|
|
49
|
+
return [makeIssue({
|
|
50
|
+
code: 'DB_SLOW',
|
|
51
|
+
component: 'Database',
|
|
52
|
+
severity: 'warning',
|
|
53
|
+
message: `Database connection slow: ${duration}ms`,
|
|
54
|
+
durationMs: duration,
|
|
55
|
+
fix: 'Check database performance and connection pool settings',
|
|
56
|
+
})];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return [];
|
|
60
|
+
} catch (err) {
|
|
61
|
+
return [makeIssue({
|
|
62
|
+
code: 'DB_DOWN',
|
|
63
|
+
component: 'Database',
|
|
64
|
+
severity: 'critical',
|
|
65
|
+
message: `Database connection failed: ${err.message}`,
|
|
66
|
+
rootCause: err.stack,
|
|
67
|
+
fix: 'Verify DATABASE_URL and database server status',
|
|
68
|
+
})];
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Check disk space
|
|
74
|
+
*/
|
|
75
|
+
export const checkDiskSpace: CerberCheck = async (ctx) => {
|
|
76
|
+
// This is OS-specific, simplified example
|
|
77
|
+
try {
|
|
78
|
+
const stats = fs.statfsSync(ctx.rootDir);
|
|
79
|
+
const freePercent = (stats.bavail / stats.blocks) * 100;
|
|
80
|
+
|
|
81
|
+
if (freePercent < 10) {
|
|
82
|
+
return [makeIssue({
|
|
83
|
+
code: 'DISK_LOW',
|
|
84
|
+
component: 'System',
|
|
85
|
+
severity: 'critical',
|
|
86
|
+
message: `Disk space critically low: ${freePercent.toFixed(1)}% free`,
|
|
87
|
+
fix: 'Free up disk space or increase volume size',
|
|
88
|
+
details: { freePercent },
|
|
89
|
+
})];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (freePercent < 20) {
|
|
93
|
+
return [makeIssue({
|
|
94
|
+
code: 'DISK_WARNING',
|
|
95
|
+
component: 'System',
|
|
96
|
+
severity: 'warning',
|
|
97
|
+
message: `Disk space running low: ${freePercent.toFixed(1)}% free`,
|
|
98
|
+
details: { freePercent },
|
|
99
|
+
})];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return [];
|
|
103
|
+
} catch (err) {
|
|
104
|
+
return [makeIssue({
|
|
105
|
+
code: 'DISK_CHECK_FAILED',
|
|
106
|
+
component: 'System',
|
|
107
|
+
severity: 'warning',
|
|
108
|
+
message: `Unable to check disk space: ${err.message}`,
|
|
109
|
+
})];
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Check if required files exist
|
|
115
|
+
*/
|
|
116
|
+
export const checkRequiredFiles: CerberCheck = async (ctx) => {
|
|
117
|
+
const required = [
|
|
118
|
+
'.env',
|
|
119
|
+
'package.json',
|
|
120
|
+
'package-lock.json',
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const missing = required.filter(file =>
|
|
124
|
+
!fs.existsSync(path.join(ctx.rootDir, file))
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (missing.length > 0) {
|
|
128
|
+
return [makeIssue({
|
|
129
|
+
code: 'FILES_MISSING',
|
|
130
|
+
component: 'Configuration',
|
|
131
|
+
severity: 'error',
|
|
132
|
+
message: `Missing required files: ${missing.join(', ')}`,
|
|
133
|
+
fix: 'Create missing configuration files',
|
|
134
|
+
details: { missing },
|
|
135
|
+
})];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return [];
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Check memory usage
|
|
143
|
+
*/
|
|
144
|
+
export const checkMemoryUsage: CerberCheck = async (ctx) => {
|
|
145
|
+
const usage = process.memoryUsage();
|
|
146
|
+
const heapUsedPercent = (usage.heapUsed / usage.heapTotal) * 100;
|
|
147
|
+
|
|
148
|
+
if (heapUsedPercent > 90) {
|
|
149
|
+
return [makeIssue({
|
|
150
|
+
code: 'MEMORY_HIGH',
|
|
151
|
+
component: 'System',
|
|
152
|
+
severity: 'critical',
|
|
153
|
+
message: `Memory usage critically high: ${heapUsedPercent.toFixed(1)}%`,
|
|
154
|
+
fix: 'Restart application or investigate memory leaks',
|
|
155
|
+
details: {
|
|
156
|
+
heapUsed: `${(usage.heapUsed / 1024 / 1024).toFixed(2)} MB`,
|
|
157
|
+
heapTotal: `${(usage.heapTotal / 1024 / 1024).toFixed(2)} MB`,
|
|
158
|
+
},
|
|
159
|
+
})];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return [];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Check package.json and lock file sync
|
|
167
|
+
*/
|
|
168
|
+
export const checkPackageLockSync: CerberCheck = async (ctx) => {
|
|
169
|
+
const packagePath = path.join(ctx.rootDir, 'package.json');
|
|
170
|
+
const lockPath = path.join(ctx.rootDir, 'package-lock.json');
|
|
171
|
+
|
|
172
|
+
if (!fs.existsSync(lockPath)) {
|
|
173
|
+
return [makeIssue({
|
|
174
|
+
code: 'LOCK_MISSING',
|
|
175
|
+
component: 'Dependencies',
|
|
176
|
+
severity: 'warning',
|
|
177
|
+
message: 'package-lock.json is missing',
|
|
178
|
+
fix: 'Run npm install to generate lock file',
|
|
179
|
+
})];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const packageMtime = fs.statSync(packagePath).mtime;
|
|
183
|
+
const lockMtime = fs.statSync(lockPath).mtime;
|
|
184
|
+
|
|
185
|
+
if (packageMtime > lockMtime) {
|
|
186
|
+
return [makeIssue({
|
|
187
|
+
code: 'LOCK_OUTDATED',
|
|
188
|
+
component: 'Dependencies',
|
|
189
|
+
severity: 'warning',
|
|
190
|
+
message: 'package-lock.json is older than package.json',
|
|
191
|
+
fix: 'Run npm install to update lock file',
|
|
192
|
+
})];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return [];
|
|
196
|
+
};
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
# Cerber SOLO Integration Example
|
|
2
|
+
|
|
3
|
+
This example shows how to integrate Cerber SOLO with your existing Guardian + Cerber setup.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📁 Project Structure
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
your-project/
|
|
11
|
+
├── solo/ # Cerber SOLO tools
|
|
12
|
+
│ ├── scripts/ # Automation scripts
|
|
13
|
+
│ ├── lib/ # Feature flags
|
|
14
|
+
│ └── config/ # Configuration
|
|
15
|
+
├── package.json # With SOLO scripts
|
|
16
|
+
├── README.md # Project documentation
|
|
17
|
+
└── .gitignore # Excludes snapshots
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📦 package.json Setup
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"name": "my-backend-api",
|
|
27
|
+
"version": "1.0.0",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"dev": "ts-node src/server.ts",
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"test": "jest",
|
|
32
|
+
|
|
33
|
+
"cerber:morning": "node solo/scripts/cerber-daily-check.js",
|
|
34
|
+
"cerber:repair": "node solo/scripts/cerber-auto-repair.js",
|
|
35
|
+
"cerber:repair:dry": "node solo/scripts/cerber-auto-repair.js --dry-run",
|
|
36
|
+
"cerber:deps": "node solo/scripts/cerber-deps-health.js",
|
|
37
|
+
"cerber:perf": "node solo/scripts/cerber-performance-budget.js",
|
|
38
|
+
"cerber:docs": "node solo/scripts/cerber-docs-sync.js",
|
|
39
|
+
"cerber:flags": "node solo/scripts/cerber-flags-check.js",
|
|
40
|
+
"cerber:snapshot": "node solo/scripts/cerber-snapshot.js",
|
|
41
|
+
"cerber:dashboard": "node solo/scripts/cerber-dashboard.js",
|
|
42
|
+
"cerber:pre-push": "npm run cerber:deps && npm run cerber:docs && npm run cerber:perf"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 📅 Daily Workflow
|
|
50
|
+
|
|
51
|
+
### Morning Routine (2 minutes)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 1. Start your day with the morning dashboard
|
|
55
|
+
npm run cerber:morning
|
|
56
|
+
|
|
57
|
+
# Output:
|
|
58
|
+
# ☀️ Morning Dashboard
|
|
59
|
+
# - Backend health: ✅ healthy
|
|
60
|
+
# - Guardian: ✅ installed
|
|
61
|
+
# - Git status: 3 files changed
|
|
62
|
+
# - Yesterday: 5 commits, +120 -45 lines
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**What to do:**
|
|
66
|
+
- Review backend health
|
|
67
|
+
- Check git status
|
|
68
|
+
- Plan today's work
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### During Development
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# 2. Auto-fix common issues
|
|
76
|
+
npm run cerber:repair
|
|
77
|
+
|
|
78
|
+
# 3. Write your code
|
|
79
|
+
# ... develop features ...
|
|
80
|
+
|
|
81
|
+
# 4. Commit (Guardian validates automatically)
|
|
82
|
+
git add .
|
|
83
|
+
git commit -m "feat: add new endpoint"
|
|
84
|
+
|
|
85
|
+
# If Guardian blocks:
|
|
86
|
+
# - Review the violation
|
|
87
|
+
# - Fix or add ARCHITECT_APPROVED comment
|
|
88
|
+
# - Try again
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Weekly Check (5 minutes)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Run dependency health check (once per week)
|
|
97
|
+
npm run cerber:deps
|
|
98
|
+
|
|
99
|
+
# Output:
|
|
100
|
+
# 🏥 Dependency Health Check
|
|
101
|
+
# ✅ Health Score: 85/100 (Grade: B)
|
|
102
|
+
#
|
|
103
|
+
# Issues:
|
|
104
|
+
# 1. [MODERATE] 3 outdated packages
|
|
105
|
+
# → Run: npm update
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**What to do:**
|
|
109
|
+
- Review health score
|
|
110
|
+
- Run suggested fixes
|
|
111
|
+
- Update dependencies
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### Before Pushing (3 minutes)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Run comprehensive pre-push checks
|
|
119
|
+
npm run cerber:pre-push
|
|
120
|
+
|
|
121
|
+
# This runs:
|
|
122
|
+
# 1. Dependency health check
|
|
123
|
+
# 2. Documentation sync
|
|
124
|
+
# 3. Performance budget
|
|
125
|
+
|
|
126
|
+
# If any fail:
|
|
127
|
+
# - Review the issues
|
|
128
|
+
# - Fix them
|
|
129
|
+
# - Run again
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### End of Day (1 minute)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Capture today's snapshot
|
|
138
|
+
npm run cerber:snapshot
|
|
139
|
+
|
|
140
|
+
# Output:
|
|
141
|
+
# 📸 Daily Snapshot
|
|
142
|
+
# ✅ Total commits: 125
|
|
143
|
+
# ✅ Today's commits: 3
|
|
144
|
+
# ✅ Files changed: 5
|
|
145
|
+
# ✅ Lines: +180 -45
|
|
146
|
+
#
|
|
147
|
+
# 💾 Saved to: .cerber/snapshots/2026-01-02.json
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 🔄 Integration with Guardian
|
|
153
|
+
|
|
154
|
+
Cerber SOLO works **alongside** Guardian, not instead of it:
|
|
155
|
+
|
|
156
|
+
### Pre-commit (Guardian)
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
git commit
|
|
160
|
+
# → Guardian validates architecture rules
|
|
161
|
+
# → Blocks commit if violations found
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Pre-push (SOLO)
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm run cerber:pre-push
|
|
168
|
+
# → Checks dependencies
|
|
169
|
+
# → Validates documentation
|
|
170
|
+
# → Enforces performance budget
|
|
171
|
+
# → You manually run this before pushing
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Post-deploy (Cerber 2.1)
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
curl https://your-api.com/api/health
|
|
178
|
+
# → Validates production health
|
|
179
|
+
# → Returns detailed diagnostics
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 🎯 Example Scenario: Adding New Feature
|
|
185
|
+
|
|
186
|
+
### 1. Morning
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npm run cerber:morning
|
|
190
|
+
# Review status, plan work
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 2. Create Feature Branch
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
git checkout -b feature/user-search
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 3. Develop
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// src/routes/users.ts
|
|
203
|
+
import { Router } from 'express';
|
|
204
|
+
import { authenticateToken } from '../middleware/auth';
|
|
205
|
+
|
|
206
|
+
const router = Router();
|
|
207
|
+
|
|
208
|
+
router.get('/search', authenticateToken, async (req, res) => {
|
|
209
|
+
// ... implementation
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### 4. Auto-fix Issues
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
npm run cerber:repair
|
|
217
|
+
# Formats package.json
|
|
218
|
+
# Syncs .env.example
|
|
219
|
+
# Generates CHANGELOG
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 5. Commit (Guardian validates)
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
git add .
|
|
226
|
+
git commit -m "feat: add user search endpoint"
|
|
227
|
+
# Guardian checks:
|
|
228
|
+
# ✅ Router imported from express
|
|
229
|
+
# ✅ authenticateToken middleware used
|
|
230
|
+
# ✅ No forbidden patterns
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 6. Before Push
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm run cerber:pre-push
|
|
237
|
+
# Checks dependencies: ✅ healthy
|
|
238
|
+
# Validates docs: ⚠️ /search not in README
|
|
239
|
+
# Performance: ✅ within budget
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 7. Fix Documentation
|
|
243
|
+
|
|
244
|
+
```markdown
|
|
245
|
+
<!-- README.md -->
|
|
246
|
+
### User Search
|
|
247
|
+
GET /api/users/search?q=john
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### 8. Push
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
git push origin feature/user-search
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 9. End of Day
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
npm run cerber:snapshot
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 🚨 Handling Issues
|
|
265
|
+
|
|
266
|
+
### Dependency Vulnerabilities
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
npm run cerber:deps
|
|
270
|
+
# Output: 🔴 Critical: 2 vulnerabilities
|
|
271
|
+
|
|
272
|
+
npm audit fix
|
|
273
|
+
npm run cerber:deps
|
|
274
|
+
# Output: ✅ Health Score: 95/100
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Performance Budget Violation
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
npm run cerber:perf
|
|
281
|
+
# Output: 🔴 Bundle size: 520 KB (limit: 500 KB)
|
|
282
|
+
|
|
283
|
+
# Fix by:
|
|
284
|
+
# 1. Enable code splitting
|
|
285
|
+
# 2. Use dynamic imports
|
|
286
|
+
# 3. Remove unused dependencies
|
|
287
|
+
|
|
288
|
+
npm run build
|
|
289
|
+
npm run cerber:perf
|
|
290
|
+
# Output: ✅ All budgets met
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Documentation Out of Sync
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
npm run cerber:docs
|
|
297
|
+
# Output: ⚠️ 3 endpoints not in README
|
|
298
|
+
|
|
299
|
+
# Add to README.md
|
|
300
|
+
npm run cerber:docs
|
|
301
|
+
# Output: ✅ Documentation in sync
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## 📊 Snapshot History
|
|
307
|
+
|
|
308
|
+
Snapshots are saved to `.cerber/snapshots/`:
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
.cerber/snapshots/
|
|
312
|
+
├── 2026-01-01.json
|
|
313
|
+
├── 2026-01-02.json
|
|
314
|
+
└── 2026-01-03.json
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Add to .gitignore:**
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
.cerber/snapshots/
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Viewing Snapshots
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
cat .cerber/snapshots/2026-01-02.json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
```json
|
|
330
|
+
{
|
|
331
|
+
"date": "2026-01-02",
|
|
332
|
+
"git": {
|
|
333
|
+
"totalCommits": 125,
|
|
334
|
+
"commitsToday": 3,
|
|
335
|
+
"filesChanged": 5,
|
|
336
|
+
"linesAdded": 180,
|
|
337
|
+
"linesRemoved": 45
|
|
338
|
+
},
|
|
339
|
+
"files": {
|
|
340
|
+
".ts": 45,
|
|
341
|
+
".js": 12
|
|
342
|
+
},
|
|
343
|
+
"loc": {
|
|
344
|
+
"total": 5420
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## 🎨 Feature Flags Example
|
|
352
|
+
|
|
353
|
+
### Define Flags
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// solo/lib/feature-flags.ts
|
|
357
|
+
export const FLAGS = {
|
|
358
|
+
"new-search": {
|
|
359
|
+
enabled: true,
|
|
360
|
+
description: "New user search endpoint",
|
|
361
|
+
owner: "backend-team",
|
|
362
|
+
environments: ["development", "staging"]
|
|
363
|
+
},
|
|
364
|
+
"beta-export": {
|
|
365
|
+
enabled: false,
|
|
366
|
+
description: "Beta export feature",
|
|
367
|
+
owner: "backend-team",
|
|
368
|
+
expiresAt: "2026-03-01"
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Use in Code
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
import { isFeatureEnabled } from './solo/lib/feature-flags';
|
|
377
|
+
|
|
378
|
+
router.get('/search', async (req, res) => {
|
|
379
|
+
if (isFeatureEnabled('new-search')) {
|
|
380
|
+
// New search implementation
|
|
381
|
+
} else {
|
|
382
|
+
// Old search implementation
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Check Flags
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
npm run cerber:flags
|
|
391
|
+
# Output:
|
|
392
|
+
# 📊 Feature Flags Summary
|
|
393
|
+
# Total: 2
|
|
394
|
+
# ✅ Enabled: 1
|
|
395
|
+
# ❌ Disabled: 1
|
|
396
|
+
#
|
|
397
|
+
# ⏰ Expired Flags:
|
|
398
|
+
# 🔴 beta-export (expired: 2026-03-01)
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## 🔧 Configuration
|
|
404
|
+
|
|
405
|
+
### Adjust Performance Budget
|
|
406
|
+
|
|
407
|
+
Edit `solo/config/performance-budget.json`:
|
|
408
|
+
|
|
409
|
+
```json
|
|
410
|
+
{
|
|
411
|
+
"bundleSize": {
|
|
412
|
+
"max": 750, // Increase to 750 KB
|
|
413
|
+
"warning": 600
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Customize Auto-Repair
|
|
419
|
+
|
|
420
|
+
Edit `solo/config/solo-contract.json`:
|
|
421
|
+
|
|
422
|
+
```json
|
|
423
|
+
{
|
|
424
|
+
"autoRepair": {
|
|
425
|
+
"enabled": true,
|
|
426
|
+
"safe": [
|
|
427
|
+
"format-package-json",
|
|
428
|
+
"sync-env"
|
|
429
|
+
// Remove "changelog" if you maintain it manually
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## 📚 Resources
|
|
438
|
+
|
|
439
|
+
- **[Complete SOLO Documentation](../../docs/SOLO.md)**
|
|
440
|
+
- **[Main README](../../README.md)**
|
|
441
|
+
- **[Guardian Setup](../../README.md#guardian-setup)**
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## 🤝 Contributing
|
|
446
|
+
|
|
447
|
+
This is an example project. For actual contributions, see the main repository.
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## 📄 License
|
|
452
|
+
|
|
453
|
+
MIT © 2026 Stefan Pitek
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
**Example built for solo developers using Cerber SOLO**
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-backend-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Example backend API with Cerber SOLO integration",
|
|
5
|
+
"main": "src/server.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "ts-node src/server.ts",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/server.js",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"lint": "eslint src/**/*.ts",
|
|
12
|
+
|
|
13
|
+
"cerber:morning": "node ../../solo/scripts/cerber-daily-check.js",
|
|
14
|
+
"cerber:repair": "node ../../solo/scripts/cerber-auto-repair.js",
|
|
15
|
+
"cerber:repair:dry": "node ../../solo/scripts/cerber-auto-repair.js --dry-run",
|
|
16
|
+
"cerber:deps": "node ../../solo/scripts/cerber-deps-health.js",
|
|
17
|
+
"cerber:perf": "node ../../solo/scripts/cerber-performance-budget.js",
|
|
18
|
+
"cerber:docs": "node ../../solo/scripts/cerber-docs-sync.js",
|
|
19
|
+
"cerber:flags": "node ../../solo/scripts/cerber-flags-check.js",
|
|
20
|
+
"cerber:snapshot": "node ../../solo/scripts/cerber-snapshot.js",
|
|
21
|
+
"cerber:dashboard": "node ../../solo/scripts/cerber-dashboard.js",
|
|
22
|
+
|
|
23
|
+
"cerber:pre-push": "npm run cerber:deps && npm run cerber:docs && npm run cerber:perf",
|
|
24
|
+
"cerber:rollback": "node ../../solo/scripts/cerber-rollback.js"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"backend",
|
|
28
|
+
"api",
|
|
29
|
+
"cerber",
|
|
30
|
+
"guardian",
|
|
31
|
+
"solo"
|
|
32
|
+
],
|
|
33
|
+
"author": "Stefan Pitek",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/express": "^4.17.21",
|
|
37
|
+
"@types/node": "^20.10.0",
|
|
38
|
+
"typescript": "^5.3.0",
|
|
39
|
+
"ts-node": "^10.9.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"eslint": "^8.55.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"express": "^4.18.2",
|
|
45
|
+
"dotenv": "^16.3.1"
|
|
46
|
+
}
|
|
47
|
+
}
|