Зеркало QuickBooks qbo_* (миграция 032) и загрузка POST /sync в qbo_auth, задание scheduler qbo_sync (п.85)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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 запущен");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user