fix: settings db requests
This commit is contained in:
parent
3668f83693
commit
9d7745cd9b
@ -2,8 +2,8 @@ import { promises as dns } from 'dns';
|
|||||||
import { X509Certificate } from 'node:crypto';
|
import { X509Certificate } from 'node:crypto';
|
||||||
|
|
||||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
import { checkDomainsIsValidInDNS, decrypt, encrypt, errorHandler, getDomain, isDNSValid, isDomainConfigured, listSettings, prisma } from '../../../../lib/common';
|
import { asyncExecShell, checkDomainsIsValidInDNS, decrypt, encrypt, errorHandler, isDNSValid, isDomainConfigured, listSettings, prisma } from '../../../../lib/common';
|
||||||
import { CheckDNS, CheckDomain, DeleteDomain, DeleteSSHKey, OnlyIdInBody, SaveSettings, SaveSSHKey } from './types';
|
import { CheckDNS, CheckDomain, DeleteDomain, OnlyIdInBody, SaveSettings, SaveSSHKey } from './types';
|
||||||
|
|
||||||
|
|
||||||
export async function listAllSettings(request: FastifyRequest) {
|
export async function listAllSettings(request: FastifyRequest) {
|
||||||
@ -17,7 +17,7 @@ export async function listAllSettings(request: FastifyRequest) {
|
|||||||
unencryptedKeys.push({ id: key.id, name: key.name, privateKey: decrypt(key.privateKey), createdAt: key.createdAt })
|
unencryptedKeys.push({ id: key.id, name: key.name, privateKey: decrypt(key.privateKey), createdAt: key.createdAt })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const certificates = await prisma.certificate.findMany({ where: { team: { every: { id: teamId } } } })
|
const certificates = await prisma.certificate.findMany({ where: { team: { id: teamId } } })
|
||||||
let cns = [];
|
let cns = [];
|
||||||
for (const certificate of certificates) {
|
for (const certificate of certificates) {
|
||||||
const x509 = new X509Certificate(certificate.cert);
|
const x509 = new X509Certificate(certificate.cert);
|
||||||
@ -140,6 +140,7 @@ export async function deleteSSHKey(request: FastifyRequest<OnlyIdInBody>, reply:
|
|||||||
export async function deleteCertificates(request: FastifyRequest<OnlyIdInBody>, reply: FastifyReply) {
|
export async function deleteCertificates(request: FastifyRequest<OnlyIdInBody>, reply: FastifyReply) {
|
||||||
try {
|
try {
|
||||||
const { id } = request.body;
|
const { id } = request.body;
|
||||||
|
await asyncExecShell(`docker exec coolify-proxy sh -c 'rm -f /etc/traefik/acme/custom/${id}-key.pem /etc/traefik/acme/custom/${id}-cert.pem'`)
|
||||||
await prisma.certificate.delete({ where: { id } })
|
await prisma.certificate.delete({ where: { id } })
|
||||||
return reply.code(201).send()
|
return reply.code(201).send()
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
|
@ -2,8 +2,8 @@ import { FastifyPluginAsync } from 'fastify';
|
|||||||
import { X509Certificate } from 'node:crypto';
|
import { X509Certificate } from 'node:crypto';
|
||||||
|
|
||||||
import { encrypt, errorHandler, prisma } from '../../../../lib/common';
|
import { encrypt, errorHandler, prisma } from '../../../../lib/common';
|
||||||
import { checkDNS, checkDomain, deleteCertificates, deleteDomain, deleteSSHKey, getCertificates, listAllSettings, saveSettings, saveSSHKey } from './handlers';
|
import { checkDNS, checkDomain, deleteCertificates, deleteDomain, deleteSSHKey, listAllSettings, saveSettings, saveSSHKey } from './handlers';
|
||||||
import { CheckDNS, CheckDomain, DeleteDomain, DeleteSSHKey, OnlyIdInBody, SaveSettings, SaveSSHKey } from './types';
|
import { CheckDNS, CheckDomain, DeleteDomain, OnlyIdInBody, SaveSettings, SaveSSHKey } from './types';
|
||||||
|
|
||||||
|
|
||||||
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user