Зеркало QuickBooks qbo_* (миграция 032) и загрузка POST /sync в qbo_auth, задание scheduler qbo_sync (п.85)
All checks were successful
ci / test (push) Successful in 36s
ci / deploy (push) Successful in 2m33s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 23:32:36 +03:00
parent d8926bc6dc
commit 12e331efe9
7 changed files with 569 additions and 3 deletions

View File

@@ -1,9 +1,10 @@
import { createLogger, createPool, itNotify, loadServiceSettings } from "khb_common";
import { createLogger, createPool, itNotify, loadServiceSettings, withTx } from "khb_common";
import { parseKey } from "./crypto.js";
import { buildApi } from "./http-api.js";
import { QboAuth } from "./service.js";
import { qboAuthSchema } from "./settings.js";
import { PgStore } from "./store.js";
import { QboSync } from "./sync.js";
const { common, service: s } = loadServiceSettings("qbo_auth", qboAuthSchema);
const log = createLogger("qbo_auth", common.logLevel);
@@ -22,7 +23,15 @@ const auth = new QboAuth({
},
});
const app = buildApi(auth, s.http.token);
const sync = new QboSync({
tx: (fn) => withTx(pool, fn),
query: (sql, params) => pool.query(sql, params),
getToken: (opts) => auth.getAccessToken(opts),
fetchFn: (url, init) => fetch(url, init),
environment: s.environment,
log: (msg, extra) => log.info(extra ?? {}, msg),
});
const app = buildApi(auth, s.http.token, sync);
await app.listen({ host: s.http.host, port: s.http.port });
log.info({ port: s.http.port, environment: s.environment }, "qbo_auth запущен");