bro-framework 3.0.2 → 3.0.3
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/bin/bro.js +2 -2
- package/package.json +1 -1
- package/src/dashboard/dashboard.html +11 -11
- package/src/locale.js +9 -2
- package/src/tasks.js +2 -1
package/bin/bro.js
CHANGED
|
@@ -45,7 +45,7 @@ async function bootstrap() {
|
|
|
45
45
|
db = globalConfig.db;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const { app, server, routes, reload, reloadLocale, shutdown } = await createServer(globalConfig, routesDir, db);
|
|
48
|
+
const { app, server, routes, reload, reloadLocale, reloadTasks, shutdown } = await createServer(globalConfig, routesDir, db);
|
|
49
49
|
let currentRoutes = routes;
|
|
50
50
|
|
|
51
51
|
server.listen(port, () => {
|
|
@@ -93,7 +93,7 @@ async function bootstrap() {
|
|
|
93
93
|
if (isLocaleFile) {
|
|
94
94
|
await reloadLocale();
|
|
95
95
|
} else if (isTaskFile) {
|
|
96
|
-
|
|
96
|
+
await reloadTasks();
|
|
97
97
|
} else {
|
|
98
98
|
currentRoutes = await reload();
|
|
99
99
|
}
|
package/package.json
CHANGED
|
@@ -115,31 +115,31 @@
|
|
|
115
115
|
item.className = 'route-item';
|
|
116
116
|
|
|
117
117
|
item.innerHTML = `
|
|
118
|
-
<div class="route-header" onclick="toggleRoute(
|
|
119
|
-
<div class="method-pill method
|
|
120
|
-
<div class="route-path" title="Click to expand/collapse"
|
|
118
|
+
<div class="route-header" onclick="toggleRoute(${idx})">
|
|
119
|
+
<div class="method-pill method-${method}">${method}</div>
|
|
120
|
+
<div class="route-path" title="Click to expand/collapse">${path}</div>
|
|
121
121
|
<div class="badges">
|
|
122
|
-
<div class="badge
|
|
123
|
-
<div class="badge
|
|
124
|
-
<div class="badge
|
|
122
|
+
<div class="badge ${r.auth !== 'public' ? 'active' : ''}">AUTH: ${r.auth}</div>
|
|
123
|
+
<div class="badge ${r.rateLimit !== 'none' ? 'active' : ''}">RL: ${r.rateLimit}</div>
|
|
124
|
+
<div class="badge ${r.cache !== 'none' ? 'active' : ''}">CACHE: ${r.cache}</div>
|
|
125
125
|
</div>
|
|
126
126
|
</div>
|
|
127
|
-
<div class="route-details" id="details
|
|
127
|
+
<div class="route-details" id="details-${idx}">
|
|
128
128
|
<div class="detail-row">
|
|
129
129
|
<div class="detail-label">Body</div>
|
|
130
|
-
<div class="detail-value"
|
|
130
|
+
<div class="detail-value">${r.hasBodySchema ? 'Schema Validated' : 'Any'}</div>
|
|
131
131
|
</div>
|
|
132
132
|
<div class="detail-row">
|
|
133
133
|
<div class="detail-label">Query</div>
|
|
134
|
-
<div class="detail-value"
|
|
134
|
+
<div class="detail-value">${r.hasQuerySchema ? 'Schema Validated' : 'Any'}</div>
|
|
135
135
|
</div>
|
|
136
136
|
<div class="detail-row">
|
|
137
137
|
<div class="detail-label">Params</div>
|
|
138
|
-
<div class="detail-value"
|
|
138
|
+
<div class="detail-value">${r.hasParamsSchema ? 'Schema Validated' : 'Any'}</div>
|
|
139
139
|
</div>
|
|
140
140
|
<div class="detail-row">
|
|
141
141
|
<div class="detail-label">Response</div>
|
|
142
|
-
<div class="detail-value"
|
|
142
|
+
<div class="detail-value">${r.hasResponseSchema ? 'Schema Validated' : 'Any'}</div>
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
145
|
`;
|
package/src/locale.js
CHANGED
|
@@ -81,8 +81,15 @@ export async function loadLocale(directory, options = {}) {
|
|
|
81
81
|
|
|
82
82
|
const messages = {};
|
|
83
83
|
for (const file of files) {
|
|
84
|
-
const
|
|
85
|
-
|
|
84
|
+
const fullPath = path.join(directory, file);
|
|
85
|
+
let catalog;
|
|
86
|
+
if (file.endsWith('.json')) {
|
|
87
|
+
catalog = JSON.parse(fs.readFileSync(fullPath, 'utf8'));
|
|
88
|
+
} else {
|
|
89
|
+
const module = await import(`${pathToFileURL(fullPath).href}?update=${crypto.randomUUID()}`);
|
|
90
|
+
catalog = module.default || module.messages || module;
|
|
91
|
+
}
|
|
92
|
+
|
|
86
93
|
if (catalog && typeof catalog === 'object') {
|
|
87
94
|
messages[localeFromFilename(file)] = catalog;
|
|
88
95
|
}
|
package/src/tasks.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
+
import crypto from 'node:crypto';
|
|
4
5
|
import cron from 'node-cron';
|
|
5
6
|
import { colors } from './logger.js';
|
|
6
7
|
import { scanDir } from './router.js';
|
|
@@ -27,7 +28,7 @@ export async function scanTasks(ctx) {
|
|
|
27
28
|
let count = 0;
|
|
28
29
|
for (const file of files) {
|
|
29
30
|
try {
|
|
30
|
-
const moduleUrl = pathToFileURL(file).href
|
|
31
|
+
const moduleUrl = `${pathToFileURL(file).href}?update=${crypto.randomUUID()}`;
|
|
31
32
|
const taskModule = await import(moduleUrl);
|
|
32
33
|
|
|
33
34
|
if (taskModule.cron && typeof taskModule.handler === 'function') {
|