mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-15 16:34:52 +02:00
Import the gerbil endpoint into the database
This commit is contained in:
parent
c857a9bd76
commit
c1f0242386
1 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
import { db } from "@server/db";
|
||||
import { orgs, resources } from "../db/schema";
|
||||
import { exitNodes, orgs, resources } from "../db/schema";
|
||||
import config from "@server/lib/config";
|
||||
import { eq, ne } from "drizzle-orm";
|
||||
import logger from "@server/logger";
|
||||
|
@ -7,11 +7,15 @@ import logger from "@server/logger";
|
|||
export async function copyInConfig() {
|
||||
// create a url from config.getRawConfig().app.base_url and get the hostname
|
||||
const domain = config.getBaseDomain();
|
||||
const endpoint = config.getRawConfig().gerbil.base_endpoint;
|
||||
|
||||
// update the domain on all of the orgs where the domain is not equal to the new domain
|
||||
// TODO: eventually each org could have a unique domain that we do not want to overwrite, so this will be unnecessary
|
||||
await db.update(orgs).set({ domain }).where(ne(orgs.domain, domain));
|
||||
|
||||
// TODO: eventually each exit node could have a different endpoint
|
||||
await db.update(exitNodes).set({ endpoint }).where(ne(exitNodes.endpoint, endpoint));
|
||||
|
||||
// update all resources fullDomain to use the new domain
|
||||
await db.transaction(async (trx) => {
|
||||
const allResources = await trx.select().from(resources);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue