Convert storage layer to 100% pure local disk JSON database (.data.json)
This commit is contained in:
@@ -815,6 +815,42 @@ app.post("/api/jobs/import", (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// API 14: Local Disk Storage Persistence Engine (No Cloud / Firebase Required)
|
||||
const DATA_FILE = path.join(process.cwd(), ".data.json");
|
||||
import fs from "fs";
|
||||
|
||||
app.get("/api/local/data", (req, res) => {
|
||||
try {
|
||||
const key = String(req.query.key || "");
|
||||
if (!fs.existsSync(DATA_FILE)) {
|
||||
return res.json({});
|
||||
}
|
||||
const raw = fs.readFileSync(DATA_FILE, "utf-8");
|
||||
const store = JSON.parse(raw || "{}");
|
||||
res.json(store[key] || {});
|
||||
} catch (e: any) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/api/local/data", (req, res) => {
|
||||
try {
|
||||
const { key, items, profile } = req.body;
|
||||
let store: any = {};
|
||||
if (fs.existsSync(DATA_FILE)) {
|
||||
try { store = JSON.parse(fs.readFileSync(DATA_FILE, "utf-8") || "{}"); } catch (e) {}
|
||||
}
|
||||
if (key) {
|
||||
if (items !== undefined) store[key] = { items };
|
||||
if (profile !== undefined) store[key] = { profile };
|
||||
}
|
||||
fs.writeFileSync(DATA_FILE, JSON.stringify(store, null, 2));
|
||||
res.json({ success: true });
|
||||
} catch (e: any) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// API 10: Google Drive - List Job Application Artifacts
|
||||
app.get("/api/workspace/drive/files", async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user