fix: compile TypeScript in Docker build — dist/ was never built in CI, connection resilience code was missing from images
This commit is contained in:
parent
95ca10175f
commit
e611609580
6 changed files with 183 additions and 50 deletions
6
dist/middleware/usage.js
vendored
6
dist/middleware/usage.js
vendored
|
|
@ -1,6 +1,6 @@
|
|||
import { isProKey } from "../services/keys.js";
|
||||
import logger from "../services/logger.js";
|
||||
import pool from "../services/db.js";
|
||||
import { queryWithRetry, connectWithRetry } from "../services/db.js";
|
||||
const FREE_TIER_LIMIT = 100;
|
||||
const PRO_TIER_LIMIT = 5000;
|
||||
// In-memory cache, periodically synced to PostgreSQL
|
||||
|
|
@ -17,7 +17,7 @@ function getMonthKey() {
|
|||
}
|
||||
export async function loadUsageData() {
|
||||
try {
|
||||
const result = await pool.query("SELECT key, count, month_key FROM usage");
|
||||
const result = await queryWithRetry("SELECT key, count, month_key FROM usage");
|
||||
usage = new Map();
|
||||
for (const row of result.rows) {
|
||||
usage.set(row.key, { count: row.count, monthKey: row.month_key });
|
||||
|
|
@ -34,7 +34,7 @@ async function flushDirtyEntries() {
|
|||
if (dirtyKeys.size === 0)
|
||||
return;
|
||||
const keysToFlush = [...dirtyKeys];
|
||||
const client = await pool.connect();
|
||||
const client = await connectWithRetry();
|
||||
try {
|
||||
await client.query("BEGIN");
|
||||
for (const key of keysToFlush) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue