diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts index 314cf4548..6e78ea944 100644 --- a/src/lib/database/services.ts +++ b/src/lib/database/services.ts @@ -4,6 +4,20 @@ import cuid from 'cuid'; import { generatePassword } from '.'; import { prisma } from './common'; +export async function listServicesWithIncludes() { + return await prisma.service.findMany({ + include: { + destinationDocker: true, + minio: true, + plausibleAnalytics: true, + vscodeserver: true, + wordpress: true, + ghost: true, + meiliSearch: true + }, + orderBy: { createdAt: 'desc' } + }); +} export async function listServices(teamId: string): Promise { if (teamId === '0') { return await prisma.service.findMany({ include: { teams: true } }); diff --git a/src/lib/haproxy/configuration.ts b/src/lib/haproxy/configuration.ts index 36dded536..f2f9f500b 100644 --- a/src/lib/haproxy/configuration.ts +++ b/src/lib/haproxy/configuration.ts @@ -6,6 +6,7 @@ import crypto from 'crypto'; import { checkContainer, checkHAProxy } from '.'; import { asyncExecShell, getDomain, getEngine } from '$lib/common'; import { supportedServiceTypesAndVersions } from '$lib/components/common'; +import { listServicesWithIncludes } from '$lib/database'; const url = dev ? 'http://localhost:5555' : 'http://coolify-haproxy:5555'; @@ -208,17 +209,7 @@ export async function configureHAProxy(): Promise { } } } - const services = await db.prisma.service.findMany({ - include: { - destinationDocker: true, - minio: true, - plausibleAnalytics: true, - vscodeserver: true, - wordpress: true, - ghost: true, - meiliSearch: true - } - }); + const services = await listServicesWithIncludes(); for (const service of services) { const { fqdn, id, type, destinationDocker, destinationDockerId, updatedAt } = service; diff --git a/src/lib/letsencrypt/index.ts b/src/lib/letsencrypt/index.ts index da923c3d5..7682ecb27 100644 --- a/src/lib/letsencrypt/index.ts +++ b/src/lib/letsencrypt/index.ts @@ -7,6 +7,7 @@ import fs from 'fs/promises'; import getPort, { portNumbers } from 'get-port'; import { supportedServiceTypesAndVersions } from '$lib/components/common'; import { promises as dns } from 'dns'; +import { listServicesWithIncludes } from '$lib/database'; export async function letsEncrypt(domain: string, id?: string, isCoolify = false): Promise { try { @@ -145,18 +146,7 @@ export async function generateSSLCerts(): Promise { console.log(`Error during generateSSLCerts with ${application.fqdn}: ${error}`); } } - const services = await db.prisma.service.findMany({ - include: { - destinationDocker: true, - minio: true, - plausibleAnalytics: true, - vscodeserver: true, - wordpress: true, - ghost: true, - meiliSearch: true - }, - orderBy: { createdAt: 'desc' } - }); + const services = await listServicesWithIncludes(); for (const service of services) { try {