support postgresql as database option

This commit is contained in:
miloschwartz 2025-06-04 12:02:07 -04:00
parent 62a0104e70
commit 2cca561e51
No known key found for this signature in database
218 changed files with 1417 additions and 713 deletions

View file

@ -1,7 +1,7 @@
import { Request, Response, NextFunction } from "express";
import { DrizzleError, eq } from "drizzle-orm";
import { sites, resources, targets, exitNodes } from "@server/db/schemas";
import db from "@server/db";
import { sites, resources, targets, exitNodes } from "@server/db";
import { db } from "@server/db";
import logger from "@server/logger";
import createHttpError from "http-errors";
import HttpCode from "@server/types/HttpCode";
@ -29,10 +29,11 @@ export const receiveBandwidth = async (
for (const peer of bandwidthData) {
const { publicKey, bytesIn, bytesOut } = peer;
// Find the site by public key
const site = await trx.query.sites.findFirst({
where: eq(sites.pubKey, publicKey)
});
const [site] = await trx
.select()
.from(sites)
.where(eq(sites.pubKey, publicKey))
.limit(1);
if (!site) {
logger.warn(`Site not found for public key: ${publicKey}`);