mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-29 06:10:47 +00:00
Pass in db to pickPort
This commit is contained in:
@@ -161,7 +161,7 @@ export async function createTarget(
|
||||
);
|
||||
}
|
||||
|
||||
const { internalPort, targetIps } = await pickPort(site.siteId!);
|
||||
const { internalPort, targetIps } = await pickPort(site.siteId!, db);
|
||||
|
||||
if (!internalPort) {
|
||||
return next(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { db } from "@server/db";
|
||||
import { db, Transaction } from "@server/db";
|
||||
import { resources, targets } from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
const currentBannedPorts: number[] = [];
|
||||
|
||||
export async function pickPort(siteId: number): Promise<{
|
||||
export async function pickPort(siteId: number, trx: Transaction | typeof db): Promise<{
|
||||
internalPort: number;
|
||||
targetIps: string[];
|
||||
}> {
|
||||
@@ -12,7 +12,7 @@ export async function pickPort(siteId: number): Promise<{
|
||||
const targetIps: string[] = [];
|
||||
const targetInternalPorts: number[] = [];
|
||||
|
||||
const targetsRes = await db
|
||||
const targetsRes = await trx
|
||||
.select()
|
||||
.from(targets)
|
||||
.where(eq(targets.siteId, siteId));
|
||||
|
||||
@@ -153,7 +153,7 @@ export async function updateTarget(
|
||||
);
|
||||
}
|
||||
|
||||
const { internalPort, targetIps } = await pickPort(site.siteId!);
|
||||
const { internalPort, targetIps } = await pickPort(site.siteId!, db);
|
||||
|
||||
if (!internalPort) {
|
||||
return next(
|
||||
|
||||
Reference in New Issue
Block a user