btca-server 1.0.62 → 1.0.63
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/package.json +1 -1
- package/src/config/index.ts +27 -0
- package/src/config/remote.ts +1 -1
- package/src/index.ts +9 -0
package/package.json
CHANGED
package/src/config/index.ts
CHANGED
|
@@ -124,6 +124,7 @@ export namespace Config {
|
|
|
124
124
|
addResource: (resource: ResourceDefinition) => Promise<ResourceDefinition>;
|
|
125
125
|
removeResource: (name: string) => Promise<void>;
|
|
126
126
|
clearResources: () => Promise<{ cleared: number }>;
|
|
127
|
+
reload: () => Promise<void>;
|
|
127
128
|
};
|
|
128
129
|
|
|
129
130
|
const expandHome = (path: string): string => {
|
|
@@ -658,6 +659,32 @@ export namespace Config {
|
|
|
658
659
|
|
|
659
660
|
Metrics.info('config.resources.cleared', { count: clearedCount });
|
|
660
661
|
return { cleared: clearedCount };
|
|
662
|
+
},
|
|
663
|
+
|
|
664
|
+
reload: async () => {
|
|
665
|
+
// Reload the config file from disk
|
|
666
|
+
// configPath points to either project config (if it existed at startup) or global config
|
|
667
|
+
Metrics.info('config.reload.start', { configPath });
|
|
668
|
+
|
|
669
|
+
const configExists = await Bun.file(configPath).exists();
|
|
670
|
+
if (!configExists) {
|
|
671
|
+
Metrics.info('config.reload.skipped', { reason: 'file not found', configPath });
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const reloaded = await loadConfigFromPath(configPath);
|
|
676
|
+
|
|
677
|
+
// Update the appropriate config based on what we had at startup
|
|
678
|
+
if (currentProjectConfig !== null) {
|
|
679
|
+
currentProjectConfig = reloaded;
|
|
680
|
+
} else {
|
|
681
|
+
currentGlobalConfig = reloaded;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
Metrics.info('config.reload.done', {
|
|
685
|
+
resources: reloaded.resources.length,
|
|
686
|
+
configPath
|
|
687
|
+
});
|
|
661
688
|
}
|
|
662
689
|
};
|
|
663
690
|
|
package/src/config/remote.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -263,6 +263,15 @@ const createApp = (deps: {
|
|
|
263
263
|
return c.json(providers);
|
|
264
264
|
})
|
|
265
265
|
|
|
266
|
+
// POST /reload-config - Reload config from disk
|
|
267
|
+
.post('/reload-config', async (c: HonoContext) => {
|
|
268
|
+
await config.reload();
|
|
269
|
+
return c.json({
|
|
270
|
+
ok: true,
|
|
271
|
+
resources: config.resources.map((r) => r.name)
|
|
272
|
+
});
|
|
273
|
+
})
|
|
274
|
+
|
|
266
275
|
// POST /question
|
|
267
276
|
.post('/question', async (c: HonoContext) => {
|
|
268
277
|
const decoded = await decodeJson(c.req.raw, QuestionRequestSchema);
|