ledgerflow-frontend/serve.js
Adam Moussa 5708347c62 Add PO pagination and load all POs from backend
Purchase orders page now shows 20 items per page with page navigation
controls. loadPOs() fetches all pages via cursor pagination instead of
capping at 200. Search filters the full dataset and resets to page 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 13:58:28 -04:00

47 lines
1.4 KiB
JavaScript

// Simple local dev server — serves frontend on http://localhost:3000
// Usage: node serve.js (uses config.js — points to deployed API)
// node serve.js --local (uses config.local.js — points to SAM local on :3001)
const http = require("http");
const fs = require("fs");
const path = require("path");
const PORT = 3000;
const DIR = __dirname;
const LOCAL_MODE = process.argv.includes("--local");
const MIME = {
".html": "text/html",
".js": "application/javascript",
".css": "text/css",
".json": "application/json",
".png": "image/png",
".svg": "image/svg+xml",
".ico": "image/x-icon",
};
http.createServer((req, res) => {
let url = req.url.split("?")[0];
if (url === "/") url = "/login.html";
// In local mode, serve config.local.js when config.js is requested
if (LOCAL_MODE && url === "/config.js") {
url = "/config.local.js";
}
const filePath = path.join(DIR, url);
const ext = path.extname(filePath);
fs.readFile(filePath, (err, data) => {
if (err) {
res.writeHead(404);
res.end("Not found");
return;
}
res.writeHead(200, { "Content-Type": MIME[ext] || "application/octet-stream" });
res.end(data);
});
}).listen(PORT, () => {
const mode = LOCAL_MODE ? "LOCAL (API → localhost:3001)" : "DEPLOYED (API → production)";
console.log(`\n LedgerFlow frontend: http://localhost:${PORT} [${mode}]\n`);
});