update pb collection and versioning setting is now in don in package.json

This commit is contained in:
2025-12-16 14:40:51 +00:00
parent 575c6e3311
commit ef613c238a
3 changed files with 28 additions and 2 deletions
+12
View File
@@ -17,6 +17,18 @@ const logLine = (path: string, line: string) => {
} }
}; };
// Version endpoint sourced from package.json
app.get('/version', (c) => {
try {
const pkgRaw = fs.readFileSync('./package.json', 'utf-8');
const pkg = JSON.parse(pkgRaw);
return c.json({ version: pkg.version || '0.0.0' });
} catch (err) {
logLine('logs/error.log', `version endpoint error: ${(err as Error)?.message || String(err)}`);
return c.json({ version: '0.0.0' }, 200);
}
});
// Serve static files from the frontend directory // Serve static files from the frontend directory
app.use('/*', serveStatic({ root: './frontend' })); app.use('/*', serveStatic({ root: './frontend' }));
+15 -2
View File
@@ -54,7 +54,7 @@
</div> </div>
<div id="results" aria-live="polite" class="flex flex-col gap-3 flex-1 overflow-auto p-0"></div> <div id="results" aria-live="polite" class="flex flex-col gap-3 flex-1 overflow-auto p-0"></div>
<div class="text-right text-xs text-gray-500 mt-5 pt-3 border-t border-gray-200"><v1 class="0 0-beta3"></v1></div> <div class="text-right text-xs text-gray-500 mt-5 pt-3 border-t border-gray-200"><span id="versionLabel">v1.0.0-beta2</span></div>
</div> </div>
<!-- Detail Modal --> <!-- Detail Modal -->
@@ -120,7 +120,7 @@
const headers = { ...(options.headers||{}), ...authHeaders() }; const headers = { ...(options.headers||{}), ...authHeaders() };
return fetch(url + `&_ts=${Date.now()}`, { ...options, headers }); return fetch(url + `&_ts=${Date.now()}`, { ...options, headers });
}; };
const PB_COLLECTION_URL = "https://pocketbase.ccllc.pro/api/collections/pbc_1431294567/records"; const PB_COLLECTION_URL = "https://pocketbase.ccllc.pro/api/collections/pbc_1407612689/records";
const NOTES_COLLECTION_URL = "https://pocketbase.ccllc.pro/api/collections/notes/records"; const NOTES_COLLECTION_URL = "https://pocketbase.ccllc.pro/api/collections/notes/records";
const perPage = 50; const perPage = 50;
@@ -137,12 +137,25 @@
const jobFolderBtn = document.getElementById('jobFolderBtn'); const jobFolderBtn = document.getElementById('jobFolderBtn');
const jobNotes = document.getElementById('jobNotes'); const jobNotes = document.getElementById('jobNotes');
const newNote = document.getElementById('newNote'); const newNote = document.getElementById('newNote');
const versionLabel = document.getElementById('versionLabel');
const toolbar = document.getElementById('toolbar'); const toolbar = document.getElementById('toolbar');
const tbButtons = Array.from(toolbar.querySelectorAll('button')); const tbButtons = Array.from(toolbar.querySelectorAll('button'));
const safeLower = v => (v||'').toString().trim().toLowerCase(); const safeLower = v => (v||'').toString().trim().toLowerCase();
// Load version from backend /version endpoint so UI matches package.json
async function loadVersion(){
if(!versionLabel) return;
try{
const res = await fetch('/version');
if(!res.ok) return;
const data = await res.json().catch(()=>null);
if(data?.version) versionLabel.textContent = `v${data.version}`;
}catch(err){ /* silent */ }
}
loadVersion();
let progTimer=null; let progTimer=null;
function startProgress(){ function startProgress(){
progressBar.style.width='0%'; progressBar.style.width='0%';
+1
View File
@@ -1,5 +1,6 @@
{ {
"name": "job-info-pb", "name": "job-info-pb",
"version": "1.0.0-beta2",
"type": "module", "type": "module",
"private": true, "private": true,
"scripts": { "scripts": {