This commit is contained in:
seb
2026-09-30 09:48:01 +02:00
parent 9885c489f0
commit 280a45a11f
28 changed files with 539 additions and 16 deletions

View File

@@ -0,0 +1,23 @@
import { FIND_BY_TOKEN as MSSQL_FIND } from '../../providers/mssql/queries/posterminal.js';
import { FIND_BY_TOKEN as SQLITE_FIND } from '../../providers/sqlite3/queries/posterminal.js';
import makeRunner from '../runner.js';
export default function findByToken(provider) {
const sql = provider?.dialect === 'sqlite3' ? SQLITE_FIND : MSSQL_FIND;
/**
* Finds a posterminal by its auth token.
*
* @param {string} token - The auth token to search for.
* @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<object|null>} The posterminal row, or null if not found.
*/
return async (token, tx) => {
const trimmed = String(token ?? '').trim();
if (!trimmed) return null;
const result = await makeRunner(provider, tx).query(sql, {
token: trimmed,
});
return result.rows[0] || null;
};
}