photo_server_json_flutter_c.../api_v1/scanner/postWithAuth.js
2026-03-23 12:31:01 +01:00

24 lines
487 B
JavaScript

// scanner/postWithAuth.js
// Versione locale: niente HTTP, niente token, solo DB
module.exports = function createPostToDB(db) {
/**
* Inserisce o aggiorna un record nel DB SQLite
* (sostituisce completamente axios.post)
*/
async function postToDB(record) {
if (!record || !record.id) {
throw new Error("Record non valido");
}
await db('photos')
.insert(record)
.onConflict('id')
.merge();
return true;
}
return postToDB;
};