copyInConfig.ts 686 B

123456789101112131415
  1. import { db } from "@server/db";
  2. import { orgs } from "../db/schema";
  3. import config from "@server/config";
  4. import { ne } from "drizzle-orm";
  5. import logger from "@server/logger";
  6. export async function copyInConfig() {
  7. // create a url from config.app.base_url and get the hostname
  8. const domain = new URL(config.app.base_url).hostname;
  9. // update the domain on all of the orgs where the domain is not equal to the new domain
  10. // TODO: eventually each org could have a unique domain that we do not want to overwrite, so this will be unnecessary
  11. await db.update(orgs).set({ domain }).where(ne(orgs.domain, domain));
  12. logger.debug("Updated orgs with new domain");
  13. }