code cleanup

This commit is contained in:
Andras Bacsai 2022-02-13 13:46:51 +01:00
parent 4ed54568d3
commit 3deff162bb
13 changed files with 1 additions and 217 deletions

View File

@ -67,7 +67,6 @@ export const getTeam = (event) => {
}; };
export const getUserDetails = async (event, isAdminRequired = true) => { export const getUserDetails = async (event, isAdminRequired = true) => {
// try {
const teamId = getTeam(event); const teamId = getTeam(event);
const userId = event.locals.session.data.uid || null; const userId = event.locals.session.data.uid || null;
const { permission = 'read' } = await db.prisma.permission.findFirst({ const { permission = 'read' } = await db.prisma.permission.findFirst({
@ -91,18 +90,6 @@ export const getUserDetails = async (event, isAdminRequired = true) => {
} }
return payload; return payload;
// } catch (err) {
// console.log(err);
// return {
// teamId: null,
// userId: null,
// permission: 'read',
// status: 401,
// body: {
// message: 'You do not have permission to do this. \nAsk an admin to modify your permissions.'
// }
// };
// }
}; };
export function getEngine(engine) { export function getEngine(engine) {

View File

@ -20,9 +20,6 @@
function showActions(value) { function showActions(value) {
actionsShow = value; actionsShow = value;
// if (value === false) {
// showPassword = false;
// }
} }
function copyToClipboard() { function copyToClipboard() {
if (isHttps && navigator.clipboard) { if (isHttps && navigator.clipboard) {

View File

@ -6,7 +6,6 @@
export let description; export let description;
export let isPadding = true; export let isPadding = true;
export let disabled = false; export let disabled = false;
// export let disabledReason = '';
</script> </script>
<li class="flex items-center py-4"> <li class="flex items-center py-4">
@ -14,11 +13,6 @@
<p class="text-xs font-bold text-stone-100 md:text-base">{title}</p> <p class="text-xs font-bold text-stone-100 md:text-base">{title}</p>
<Explainer text={description} /> <Explainer text={description} />
</div> </div>
<!-- {#if disabled}
<div class="flex" class:px-4={isPadding} class:pr-32={!isPadding}>
<p class="text-xs font-bold text-stone-400">{disabledReason}</p>
</div>
{:else} -->
<div <div
type="button" type="button"
on:click on:click

View File

@ -109,22 +109,4 @@ export async function setDestinationSettings({ engine, isCoolifyProxyUsed }) {
where: { engine }, where: { engine },
data: { isCoolifyProxyUsed } data: { isCoolifyProxyUsed }
}); });
// if (isCoolifyProxyUsed) {
// await installCoolifyProxy(engine)
// await configureNetworkCoolifyProxy(engine)
// } else {
// // TODO: must check if other destination is using the proxy??? or not?
// const domain = await prisma.setting.findUnique({ where: { name: 'domain' }, rejectOnNotFound: false })
// if (!domain) {
// await uninstallCoolifyProxy(engine)
// } else {
// return {
// stastus: 500,
// body: {
// message: 'You can not disable the Coolify proxy while the domain is set for Coolify itself.'
// }
// }
// }
// }
} }

View File

@ -97,17 +97,6 @@ export async function login({ email, password }) {
}); });
} }
} }
// const token = jsonwebtoken.sign({}, secretKey, {
// expiresIn: 15778800,
// algorithm: 'HS256',
// audience: 'coolify',
// issuer: 'coolify',
// jwtid: uid,
// subject: `User:${uid}`,
// notBefore: -1000
// });
return { return {
status: 200, status: 200,
headers: { headers: {

View File

@ -188,94 +188,7 @@ export async function deleteProxy({ id }) {
await completeTransaction(transactionId); await completeTransaction(transactionId);
} }
} }
// export async function configureProxyForDatabase({ id, port, isPublic, privatePort }) {
// const haproxy = await haproxyInstance()
// try {
// await checkHAProxy()
// } catch (error) {
// return
// }
// let alreadyConfigured = false
// try {
// const backend: any = await haproxy.get(`v2/services/haproxy/configuration/backends/${id}`).json()
// const server: any = await haproxy.get(`v2/services/haproxy/configuration/servers/${id}`, {
// searchParams: {
// backend: id
// },
// }).json()
// if (backend.data.name === id) {
// if (server.data.port === privatePort) {
// if (server.data.check === 'enabled') {
// if (server.data.address === id) {
// alreadyConfigured = true
// }
// }
// }
// }
// } catch (error) {
// console.log('error getting backend or server', error.response.body)
// }
// if (alreadyConfigured) return
// const transactionId = await getNextTransactionId()
// try {
// await haproxy.post('v2/services/haproxy/configuration/backends', {
// searchParams: {
// transaction_id: transactionId
// },
// json: {
// "init-addr": "last,libc,none",
// "mode": "tcp",
// "name": id
// }
// })
// await haproxy.post('v2/services/haproxy/configuration/servers', {
// searchParams: {
// transaction_id: transactionId,
// backend: id
// },
// json: {
// "address": id,
// "check": "enabled",
// "name": id,
// "port": privatePort
// }
// })
// await haproxy.post('v2/services/haproxy/configuration/frontends', {
// searchParams: {
// transaction_id: transactionId,
// backend: id
// },
// json: {
// "default_backend": id,
// "mode": "tcp",
// "name": id
// }
// })
// await haproxy.post('v2/services/haproxy/configuration/binds', {
// searchParams: {
// transaction_id: transactionId,
// frontend: id
// },
// json: {
// "address": "*",
// "name": id,
// "port": port
// }
// })
// } catch (error) {
// console.log(error.response.body)
// throw error.response.body
// } finally {
// try {
// await completeTransaction(transactionId)
// } catch (error) {
// console.log(error.response.body)
// }
// }
// await configureDatabaseVisibility({ id, isPublic })
// }
export async function reloadHaproxy(engine) { export async function reloadHaproxy(engine) {
const host = getEngine(engine); const host = getEngine(engine);
return await asyncExecShell(`DOCKER_HOST=${host} docker exec coolify-haproxy kill -HUP 1`); return await asyncExecShell(`DOCKER_HOST=${host} docker exec coolify-haproxy kill -HUP 1`);

View File

@ -64,10 +64,6 @@ export default async function (job) {
if (destinationDockerId) { if (destinationDockerId) {
destinationType = 'docker'; destinationType = 'docker';
} }
// Not implemented yet
// if (destinationKubernetesId) {
// destinationType = 'kubernetes'
// }
if (destinationType === 'docker') { if (destinationType === 'docker') {
const docker = dockerInstance({ destinationDocker }); const docker = dockerInstance({ destinationDocker });

View File

@ -144,28 +144,6 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
}); });
}); });
// const letsEncryptQueueName = dev ? cuid() : 'letsencrypt_queue'
// const letsEncryptQueue = new Queue(letsEncryptQueueName, connectionOptions)
// const letsEncryptWorker = new Worker(letsEncryptQueueName, async (job) => await letsencrypt(job), {
// concurrency: 1,
// ...connectionOptions
// })
// letsEncryptWorker.on('completed', async () => {
// // TODO: Save letsencrypt logs as build logs!
// console.log('[DEBUG] Lets Encrypt job completed')
// })
// letsEncryptWorker.on('failed', async (job: Job, failedReason: string) => {
// try {
// await prisma.applicationSettings.updateMany({ where: { applicationId: job.data.id }, data: { forceSSL: false } })
// } catch (error) {
// console.log(error)
// }
// console.log('[DEBUG] Lets Encrypt job failed')
// console.log(failedReason)
// })
const buildLogQueueName = dev ? cuid() : 'log_queue'; const buildLogQueueName = dev ? cuid() : 'log_queue';
const buildLogQueue = new Queue(buildLogQueueName, connectionOptions); const buildLogQueue = new Queue(buildLogQueueName, connectionOptions);
const buildLogWorker = new Worker(buildLogQueueName, async (job) => await logger(job), { const buildLogWorker = new Worker(buildLogQueueName, async (job) => await logger(job), {

View File

@ -124,25 +124,6 @@
updateStatus.success = false; updateStatus.success = false;
updateStatus.loading = false; updateStatus.loading = false;
} }
// } else {
// let reachable = false;
// let tries = 0;
// do {
// await asyncSleep(1000);
// try {
// await get(`/undead.json`);
// reachable = true;
// } catch (error) {
// console.log(error);
// reachable = false;
// }
// if (reachable) break;
// tries++;
// } while (!reachable || tries < 120);
// toast.push('New version reachable. Reloading...');
// await asyncSleep(2000);
// window.location.reload();
// }
} }
</script> </script>

View File

@ -142,14 +142,6 @@
return errorNotification('Branch already configured'); return errorNotification('Branch already configured');
} }
} }
// async function saveDeployKey(deployKeyId: number) {
// try {
// await post(updateDeployKeyIdUrl, { deployKeyId });
// } catch (error) {
// errorNotification(error);
// throw new Error(error);
// }
// }
async function checkSSHKey(sshkeyUrl) { async function checkSSHKey(sshkeyUrl) {
try { try {
return await post(sshkeyUrl, {}); return await post(sshkeyUrl, {});

View File

@ -25,9 +25,7 @@ export const get: RequestHandler = async (event) => {
state = 'running'; state = 'running';
} }
} catch (error) { } catch (error) {
// if (!error.stderr.includes('No such object')) { //
// console.log(error)
// }
} }
} }
const configuration = generateDatabaseConfiguration(database); const configuration = generateDatabaseConfiguration(database);

View File

@ -46,24 +46,3 @@ export const get: RequestHandler = async (event) => {
return PrismaErrorHandler(error); return PrismaErrorHandler(error);
} }
}; };
// export const post: RequestHandler<Locals, FormData> = async (request) => {
// const { teamId, status, body } = await getUserDetails(request);
// if (status === 401) return { status, body }
// const { id } = request.params
// const name = request.body.get('name')
// const defaultDatabase = request.body.get('defaultDatabase')
// const dbUser = request.body.get('dbUser')
// const dbUserPassword = request.body.get('dbUserPassword')
// const rootUser = request.body.get('rootUser')
// const rootUserPassword = request.body.get('rootUserPassword')
// const version = request.body.get('version')
// try {
// return await db.updateDatabase({ id, name, defaultDatabase, dbUser, dbUserPassword, rootUser, rootUserPassword, version })
// } catch (err) {
// return err
// }
// }

View File

@ -71,8 +71,6 @@
window.open(`${source.htmlUrl}/groups/${payload.groupName}/-/settings/applications`); window.open(`${source.htmlUrl}/groups/${payload.groupName}/-/settings/applications`);
break; break;
case 'instance': case 'instance':
// TODO: This is not correct
// window.location.assign(`${source.htmlUrl}/-/profile/applications`);
break; break;
default: default:
break; break;