From 8ab6d6b2828d27522a9a3a1243306973b1bd0ac7 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 22 Feb 2025 20:35:21 -0600 Subject: [PATCH] chore: clean up unused variables and improve error handling across codebase This commit focuses on removing unused variables, adding placeholder error handling, and generally tidying up various files across the Dokploy application. Changes include: - Removing unused imports and variables - Adding placeholder error handling in catch blocks - Cleaning up commented-out code - Removing deprecated utility files - Improving type safety and code consistency --- .../cluster/modify-swarm-settings.tsx | 2 +- .../advanced/volumes/update-volume.tsx | 2 +- .../generic/save-bitbucket-provider.tsx | 1 - .../dashboard/application/general/show.tsx | 3 +- .../show-preview-settings.tsx | 2 +- .../dashboard/compose/delete-service.tsx | 2 +- .../compose/domains/show-domains.tsx | 2 +- .../compose/general/compose-file-editor.tsx | 5 +- .../save-bitbucket-provider-compose.tsx | 1 - .../compose/general/isolated-deployment.tsx | 2 +- .../compose/general/randomize-compose.tsx | 4 +- .../general/show-converted-compose.tsx | 2 +- .../paid/container/container-block-chart.tsx | 8 -- .../organization/handle-organization.tsx | 2 +- .../postgres/advanced/show-custom-command.tsx | 2 +- .../dashboard/project/add-application.tsx | 2 +- .../dashboard/project/add-template.tsx | 4 +- .../show-external-redis-credentials.tsx | 2 +- .../components/dashboard/requests/columns.tsx | 2 +- .../dashboard/requests/requests-table.tsx | 4 +- .../components/dashboard/search-command.tsx | 5 +- .../settings/billing/show-billing.tsx | 8 +- .../settings/cluster/nodes/show-nodes.tsx | 3 +- .../cluster/registry/handle-registry.tsx | 2 +- .../git/bitbucket/add-bitbucket-provider.tsx | 4 +- .../settings/git/show-git-providers.tsx | 2 +- .../notifications/handle-notifications.tsx | 4 +- .../notifications/show-notifications.tsx | 2 +- .../settings/profile/disable-2fa.tsx | 2 +- .../dashboard/settings/profile/enable-2fa.tsx | 12 --- .../settings/profile/profile-form.tsx | 4 +- .../servers/actions/show-storage-actions.tsx | 2 +- .../servers/actions/toggle-docker-cleanup.tsx | 2 +- .../settings/servers/edit-script.tsx | 2 +- .../settings/servers/gpu-support.tsx | 4 +- .../settings/servers/handle-servers.tsx | 2 +- .../settings/servers/security-audit.tsx | 2 +- .../settings/servers/setup-monitoring.tsx | 2 +- .../settings/servers/validate-server.tsx | 2 +- .../servers/welcome-stripe/create-server.tsx | 6 +- .../servers/welcome-stripe/verify.tsx | 9 -- .../settings/users/show-invitations.tsx | 4 +- .../dashboard/settings/users/show-users.tsx | 2 +- .../dashboard/settings/web-server.tsx | 5 +- .../web-server/manage-traefik-ports.tsx | 2 +- .../settings/web-server/update-server-ip.tsx | 2 +- .../dashboard/swarm/applications/columns.tsx | 2 +- .../swarm/applications/data-table.tsx | 2 +- .../swarm/details/show-node-config.tsx | 2 +- apps/dokploy/components/layouts/side.tsx | 25 ++--- .../components/layouts/update-server.tsx | 2 +- apps/dokploy/components/layouts/user-nav.tsx | 2 +- .../components/shared/breadcrumb-sidebar.tsx | 2 +- .../dokploy/components/shared/drawer-logs.tsx | 2 +- apps/dokploy/components/ui/file-tree.tsx | 2 +- apps/dokploy/migrate.ts | 2 +- apps/dokploy/pages/_error.tsx | 2 +- apps/dokploy/pages/api/health.ts | 2 +- .../pages/api/providers/github/setup.ts | 3 +- apps/dokploy/pages/api/stripe/webhook.ts | 46 ++++++--- apps/dokploy/pages/dashboard/docker.tsx | 2 +- apps/dokploy/pages/dashboard/monitoring.tsx | 3 +- .../pages/dashboard/project/[projectId].tsx | 6 +- .../services/application/[applicationId].tsx | 5 +- .../services/compose/[composeId].tsx | 5 +- .../services/mariadb/[mariadbId].tsx | 5 +- .../[projectId]/services/mongo/[mongoId].tsx | 5 +- .../[projectId]/services/mysql/[mysqlId].tsx | 5 +- .../services/postgres/[postgresId].tsx | 5 +- .../[projectId]/services/redis/[redisId].tsx | 5 +- .../dashboard/settings/git-providers.tsx | 2 +- .../pages/dashboard/settings/ssh-keys.tsx | 4 +- apps/dokploy/pages/dashboard/swarm.tsx | 2 +- apps/dokploy/pages/dashboard/traefik.tsx | 2 +- apps/dokploy/pages/index.tsx | 21 ++--- apps/dokploy/pages/invitation.tsx | 15 +-- apps/dokploy/pages/register.tsx | 55 +++++------ apps/dokploy/pages/reset-password.tsx | 2 +- apps/dokploy/pages/send-reset-password.tsx | 8 +- apps/dokploy/server/api/routers/auth.ts | 20 ++-- apps/dokploy/server/api/routers/server.ts | 13 +++ apps/dokploy/server/api/routers/stripe.ts | 6 +- apps/dokploy/server/db/seed.ts | 7 +- apps/dokploy/server/utils/docker.ts | 2 +- .../server/wss/docker-container-terminal.ts | 10 +- apps/dokploy/server/wss/drawer-logs.ts | 2 +- apps/dokploy/server/wss/listen-deployment.ts | 2 +- apps/dokploy/server/wss/terminal.ts | 10 +- apps/dokploy/templates/appsmith/index.ts | 2 +- apps/dokploy/templates/blender/index.ts | 2 +- apps/dokploy/templates/cloudflared/index.ts | 2 +- apps/dokploy/templates/drawio/index.ts | 2 +- apps/dokploy/templates/immich/index.ts | 2 +- apps/dokploy/templates/unifi/index.ts | 2 +- packages/server/src/db/schema/certificate.ts | 21 ++--- packages/server/src/db/schema/git-provider.ts | 2 +- packages/server/src/db/schema/registry.ts | 2 +- packages/server/src/lib/auth.ts | 77 ++++++++------- packages/server/src/lib/crypto.ts | 94 ------------------- packages/server/src/lib/scrypt/index.ts | 1 - packages/server/src/monitoring/utils.ts | 4 +- packages/server/src/services/admin.ts | 10 +- packages/server/src/services/docker.ts | 20 ++-- packages/server/src/services/github.ts | 2 +- packages/server/src/services/mount.ts | 2 +- .../server/src/services/preview-deployment.ts | 2 +- packages/server/src/setup/monitoring-setup.ts | 4 +- packages/server/src/setup/postgres-setup.ts | 2 +- packages/server/src/setup/redis-setup.ts | 2 +- packages/server/src/setup/server-audit.ts | 2 +- packages/server/src/setup/server-validate.ts | 2 +- packages/server/src/setup/setup.ts | 4 +- packages/server/src/setup/traefik-setup.ts | 2 +- packages/server/src/types/with.ts | 2 +- .../server/src/utils/access-log/handler.ts | 2 +- packages/server/src/utils/backups/utils.ts | 2 +- packages/server/src/utils/builders/compose.ts | 3 +- packages/server/src/utils/builders/index.ts | 2 +- .../server/src/utils/builders/nixpacks.ts | 2 +- .../server/src/utils/databases/mariadb.ts | 2 +- packages/server/src/utils/databases/mongo.ts | 2 +- packages/server/src/utils/databases/mysql.ts | 2 +- packages/server/src/utils/databases/redis.ts | 2 +- packages/server/src/utils/docker/domain.ts | 2 +- packages/server/src/utils/docker/utils.ts | 4 +- packages/server/src/utils/gpu-setup.ts | 4 +- .../server/src/utils/process/execAsync.ts | 2 +- .../server/src/utils/providers/bitbucket.ts | 1 - packages/server/src/utils/providers/git.ts | 2 +- packages/server/src/utils/providers/gitlab.ts | 11 +-- .../server/src/utils/traefik/application.ts | 8 +- .../verification/send-verification-email.tsx | 49 ++++++++++ 132 files changed, 375 insertions(+), 471 deletions(-) delete mode 100644 packages/server/src/lib/crypto.ts delete mode 100644 packages/server/src/lib/scrypt/index.ts create mode 100644 packages/server/src/verification/send-verification-email.tsx diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx index 9b71a042a..95a559f66 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx @@ -130,7 +130,7 @@ const createStringToJSONSchema = (schema: z.ZodTypeAny) => { } try { return JSON.parse(str); - } catch (e) { + } catch (_e) { ctx.addIssue({ code: "custom", message: "Invalid JSON format" }); return z.NEVER; } diff --git a/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx b/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx index 687d0f608..8da09b58b 100644 --- a/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx @@ -77,7 +77,7 @@ export const UpdateVolume = ({ serviceType, }: Props) => { const [isOpen, setIsOpen] = useState(false); - const utils = api.useUtils(); + const _utils = api.useUtils(); const { data } = api.mounts.one.useQuery( { mountId, diff --git a/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx b/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx index 9b207d636..9af040b79 100644 --- a/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx +++ b/apps/dokploy/components/dashboard/application/general/generic/save-bitbucket-provider.tsx @@ -84,7 +84,6 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => { data: repositories, isLoading: isLoadingRepositories, error, - isError, } = api.bitbucket.getBitbucketRepositories.useQuery( { bitbucketId, diff --git a/apps/dokploy/components/dashboard/application/general/show.tsx b/apps/dokploy/components/dashboard/application/general/show.tsx index 0ea331e94..8989ca198 100644 --- a/apps/dokploy/components/dashboard/application/general/show.tsx +++ b/apps/dokploy/components/dashboard/application/general/show.tsx @@ -27,8 +27,7 @@ export const ShowGeneralApplication = ({ applicationId }: Props) => { const { mutateAsync: stop, isLoading: isStopping } = api.application.stop.useMutation(); - const { mutateAsync: deploy, isLoading: isDeploying } = - api.application.deploy.useMutation(); + const { mutateAsync: deploy } = api.application.deploy.useMutation(); const { mutateAsync: reload, isLoading: isReloading } = api.application.reload.useMutation(); diff --git a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx index fec61ca60..9d53f31d8 100644 --- a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx +++ b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-settings.tsx @@ -279,7 +279,7 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => { ( + render={() => ( { compose: () => api.compose.one.useQuery({ composeId: id }, { enabled: !!id }), }; - const { data, refetch } = queryMap[type] + const { data } = queryMap[type] ? queryMap[type]() : api.mongo.one.useQuery({ mongoId: id }, { enabled: !!id }); diff --git a/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx b/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx index 7bc451e00..e6468d6fa 100644 --- a/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx +++ b/apps/dokploy/components/dashboard/compose/domains/show-domains.tsx @@ -118,7 +118,7 @@ export const ShowDomainsCompose = ({ composeId }: Props) => { await deleteDomain({ domainId: item.domainId, }) - .then((data) => { + .then((_data) => { refetch(); toast.success("Domain deleted successfully"); }) diff --git a/apps/dokploy/components/dashboard/compose/general/compose-file-editor.tsx b/apps/dokploy/components/dashboard/compose/general/compose-file-editor.tsx index c4ce44e52..725895821 100644 --- a/apps/dokploy/components/dashboard/compose/general/compose-file-editor.tsx +++ b/apps/dokploy/components/dashboard/compose/general/compose-file-editor.tsx @@ -35,8 +35,7 @@ export const ComposeFileEditor = ({ composeId }: Props) => { { enabled: !!composeId }, ); - const { mutateAsync, isLoading, error, isError } = - api.compose.update.useMutation(); + const { mutateAsync, isLoading } = api.compose.update.useMutation(); const form = useForm({ defaultValues: { @@ -76,7 +75,7 @@ export const ComposeFileEditor = ({ composeId }: Props) => { composeId, }); }) - .catch((e) => { + .catch((_e) => { toast.error("Error updating the Compose config"); }); }; diff --git a/apps/dokploy/components/dashboard/compose/general/generic/save-bitbucket-provider-compose.tsx b/apps/dokploy/components/dashboard/compose/general/generic/save-bitbucket-provider-compose.tsx index 1c06fe881..875841338 100644 --- a/apps/dokploy/components/dashboard/compose/general/generic/save-bitbucket-provider-compose.tsx +++ b/apps/dokploy/components/dashboard/compose/general/generic/save-bitbucket-provider-compose.tsx @@ -84,7 +84,6 @@ export const SaveBitbucketProviderCompose = ({ composeId }: Props) => { data: repositories, isLoading: isLoadingRepositories, error, - isError, } = api.bitbucket.getBitbucketRepositories.useQuery( { bitbucketId, diff --git a/apps/dokploy/components/dashboard/compose/general/isolated-deployment.tsx b/apps/dokploy/components/dashboard/compose/general/isolated-deployment.tsx index 70d685efb..3ae2e9fe3 100644 --- a/apps/dokploy/components/dashboard/compose/general/isolated-deployment.tsx +++ b/apps/dokploy/components/dashboard/compose/general/isolated-deployment.tsx @@ -70,7 +70,7 @@ export const IsolatedDeployment = ({ composeId }: Props) => { composeId, isolatedDeployment: formData?.isolatedDeployment || false, }) - .then(async (data) => { + .then(async (_data) => { randomizeCompose(); refetch(); toast.success("Compose updated"); diff --git a/apps/dokploy/components/dashboard/compose/general/randomize-compose.tsx b/apps/dokploy/components/dashboard/compose/general/randomize-compose.tsx index 4462ef0eb..4cc877fde 100644 --- a/apps/dokploy/components/dashboard/compose/general/randomize-compose.tsx +++ b/apps/dokploy/components/dashboard/compose/general/randomize-compose.tsx @@ -39,7 +39,7 @@ type Schema = z.infer; export const RandomizeCompose = ({ composeId }: Props) => { const utils = api.useUtils(); const [compose, setCompose] = useState(""); - const [isOpen, setIsOpen] = useState(false); + const [_isOpen, _setIsOpen] = useState(false); const { mutateAsync, error, isError } = api.compose.randomizeCompose.useMutation(); @@ -76,7 +76,7 @@ export const RandomizeCompose = ({ composeId }: Props) => { suffix: formData?.suffix || "", randomize: formData?.randomize || false, }) - .then(async (data) => { + .then(async (_data) => { randomizeCompose(); refetch(); toast.success("Compose updated"); diff --git a/apps/dokploy/components/dashboard/compose/general/show-converted-compose.tsx b/apps/dokploy/components/dashboard/compose/general/show-converted-compose.tsx index 8a2186d9e..49606645c 100644 --- a/apps/dokploy/components/dashboard/compose/general/show-converted-compose.tsx +++ b/apps/dokploy/components/dashboard/compose/general/show-converted-compose.tsx @@ -40,7 +40,7 @@ export const ShowConvertedCompose = ({ composeId }: Props) => { .then(() => { refetch(); }) - .catch((err) => {}); + .catch((_err) => {}); } }, [isOpen]); diff --git a/apps/dokploy/components/dashboard/monitoring/paid/container/container-block-chart.tsx b/apps/dokploy/components/dashboard/monitoring/paid/container/container-block-chart.tsx index 9150dbcde..12af6b91d 100644 --- a/apps/dokploy/components/dashboard/monitoring/paid/container/container-block-chart.tsx +++ b/apps/dokploy/components/dashboard/monitoring/paid/container/container-block-chart.tsx @@ -29,14 +29,6 @@ interface Props { data: ContainerMetric[]; } -interface FormattedMetric { - timestamp: string; - read: number; - write: number; - readUnit: string; - writeUnit: string; -} - const chartConfig = { read: { label: "Read", diff --git a/apps/dokploy/components/dashboard/organization/handle-organization.tsx b/apps/dokploy/components/dashboard/organization/handle-organization.tsx index 905a244cc..2a595f436 100644 --- a/apps/dokploy/components/dashboard/organization/handle-organization.tsx +++ b/apps/dokploy/components/dashboard/organization/handle-organization.tsx @@ -20,7 +20,7 @@ interface Props { organizationId?: string; children?: React.ReactNode; } -export function AddOrganization({ organizationId, children }: Props) { +export function AddOrganization({ organizationId }: Props) { const utils = api.useUtils(); const { data: organization } = api.organization.one.useQuery( { diff --git a/apps/dokploy/components/dashboard/postgres/advanced/show-custom-command.tsx b/apps/dokploy/components/dashboard/postgres/advanced/show-custom-command.tsx index 2bae245ec..40e84844f 100644 --- a/apps/dokploy/components/dashboard/postgres/advanced/show-custom-command.tsx +++ b/apps/dokploy/components/dashboard/postgres/advanced/show-custom-command.tsx @@ -53,7 +53,7 @@ export const ShowCustomCommand = ({ id, type }: Props) => { mongo: () => api.mongo.update.useMutation(), }; - const { mutateAsync, isLoading } = mutationMap[type] + const { mutateAsync } = mutationMap[type] ? mutationMap[type]() : api.mongo.update.useMutation(); diff --git a/apps/dokploy/components/dashboard/project/add-application.tsx b/apps/dokploy/components/dashboard/project/add-application.tsx index da30cfee3..16c56917d 100644 --- a/apps/dokploy/components/dashboard/project/add-application.tsx +++ b/apps/dokploy/components/dashboard/project/add-application.tsx @@ -103,7 +103,7 @@ export const AddApplication = ({ projectId, projectName }: Props) => { projectId, }); }) - .catch((e) => { + .catch((_e) => { toast.error("Error creating the service"); }); }; diff --git a/apps/dokploy/components/dashboard/project/add-template.tsx b/apps/dokploy/components/dashboard/project/add-template.tsx index 3965f8172..5363e6f36 100644 --- a/apps/dokploy/components/dashboard/project/add-template.tsx +++ b/apps/dokploy/components/dashboard/project/add-template.tsx @@ -434,14 +434,14 @@ export const AddTemplate = ({ projectId }: Props) => { }); toast.promise(promise, { loading: "Setting up...", - success: (data) => { + success: (_data) => { utils.project.one.invalidate({ projectId, }); setOpen(false); return `${template.name} template created successfully`; }, - error: (err) => { + error: (_err) => { return `An error ocurred deploying ${template.name} template`; }, }); diff --git a/apps/dokploy/components/dashboard/redis/general/show-external-redis-credentials.tsx b/apps/dokploy/components/dashboard/redis/general/show-external-redis-credentials.tsx index 25b5f2ba7..75112cf6e 100644 --- a/apps/dokploy/components/dashboard/redis/general/show-external-redis-credentials.tsx +++ b/apps/dokploy/components/dashboard/redis/general/show-external-redis-credentials.tsx @@ -79,7 +79,7 @@ export const ShowExternalRedisCredentials = ({ redisId }: Props) => { useEffect(() => { const buildConnectionUrl = () => { - const hostname = window.location.hostname; + const _hostname = window.location.hostname; const port = form.watch("externalPort") || data?.externalPort; return `redis://default:${data?.databasePassword}@${getIp}:${port}`; diff --git a/apps/dokploy/components/dashboard/requests/columns.tsx b/apps/dokploy/components/dashboard/requests/columns.tsx index c1814190e..2c0391f80 100644 --- a/apps/dokploy/components/dashboard/requests/columns.tsx +++ b/apps/dokploy/components/dashboard/requests/columns.tsx @@ -24,7 +24,7 @@ export const getStatusColor = (status: number) => { export const columns: ColumnDef[] = [ { accessorKey: "level", - header: ({ column }) => { + header: () => { return ; }, cell: ({ row }) => { diff --git a/apps/dokploy/components/dashboard/requests/requests-table.tsx b/apps/dokploy/components/dashboard/requests/requests-table.tsx index cd2949c34..4926ce4e3 100644 --- a/apps/dokploy/components/dashboard/requests/requests-table.tsx +++ b/apps/dokploy/components/dashboard/requests/requests-table.tsx @@ -92,7 +92,7 @@ export const RequestsTable = () => { pageSize: 10, }); - const { data: statsLogs, isLoading } = api.settings.readStatsLogs.useQuery( + const { data: statsLogs } = api.settings.readStatsLogs.useQuery( { sort: sorting[0], page: pagination, @@ -300,7 +300,7 @@ export const RequestsTable = () => { setSelectedRow(undefined)} + onOpenChange={(_open) => setSelectedRow(undefined)} > diff --git a/apps/dokploy/components/dashboard/search-command.tsx b/apps/dokploy/components/dashboard/search-command.tsx index 5726dc99a..b36703036 100644 --- a/apps/dokploy/components/dashboard/search-command.tsx +++ b/apps/dokploy/components/dashboard/search-command.tsx @@ -22,14 +22,11 @@ import { extractServices, } from "@/pages/dashboard/project/[projectId]"; import { api } from "@/utils/api"; -import type { findProjectById } from "@dokploy/server/services/project"; import { BookIcon, CircuitBoard, GlobeIcon } from "lucide-react"; import { useRouter } from "next/router"; import React from "react"; import { StatusTooltip } from "../shared/status-tooltip"; -type Project = Awaited>; - export const SearchCommand = () => { const router = useRouter(); const [open, setOpen] = React.useState(false); @@ -38,7 +35,7 @@ export const SearchCommand = () => { const { data } = api.project.all.useQuery(undefined, { enabled: !!session, }); - const { data: isCloud, isLoading } = api.settings.isCloud.useQuery(); + const { data: isCloud } = api.settings.isCloud.useQuery(); React.useEffect(() => { const down = (e: KeyboardEvent) => { diff --git a/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx b/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx index 029eaa90f..2c20bb81d 100644 --- a/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx +++ b/apps/dokploy/components/dashboard/settings/billing/show-billing.tsx @@ -38,7 +38,7 @@ export const calculatePrice = (count: number, isAnnual = false) => { return count * 3.5; }; export const ShowBilling = () => { - const { data: servers } = api.server.all.useQuery(undefined); + const { data: servers } = api.server.count.useQuery(); const { data: admin } = api.user.get.useQuery(); const { data, isLoading } = api.stripe.getProducts.useQuery(); const { mutateAsync: createCheckoutSession } = @@ -71,7 +71,7 @@ export const ShowBilling = () => { }); const maxServers = admin?.user.serversQuantity ?? 1; - const percentage = ((servers?.length ?? 0) / maxServers) * 100; + const percentage = ((servers ?? 0) / maxServers) * 100; const safePercentage = Math.min(percentage, 100); return ( @@ -102,13 +102,13 @@ export const ShowBilling = () => {

Servers Plan

- You have {servers?.length} server on your plan of{" "} + You have {servers} server on your plan of{" "} {admin?.user.serversQuantity} servers

- {admin && admin.user.serversQuantity! <= servers?.length! && ( + {admin && admin.user.serversQuantity! <= (servers ?? 0) && (
diff --git a/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes.tsx b/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes.tsx index ba3eefa56..b84c3b636 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/nodes/show-nodes.tsx @@ -41,8 +41,7 @@ export const ShowNodes = () => { const { data, isLoading, refetch } = api.cluster.getNodes.useQuery(); const { data: registry } = api.registry.all.useQuery(); - const { mutateAsync: deleteNode, isLoading: isRemoving } = - api.cluster.removeWorker.useMutation(); + const { mutateAsync: deleteNode } = api.cluster.removeWorker.useMutation(); const haveAtLeastOneRegistry = !!(registry && registry?.length > 0); return ( diff --git a/apps/dokploy/components/dashboard/settings/cluster/registry/handle-registry.tsx b/apps/dokploy/components/dashboard/settings/cluster/registry/handle-registry.tsx index 78f3b868a..55daedca2 100644 --- a/apps/dokploy/components/dashboard/settings/cluster/registry/handle-registry.tsx +++ b/apps/dokploy/components/dashboard/settings/cluster/registry/handle-registry.tsx @@ -131,7 +131,7 @@ export const HandleRegistry = ({ registryId }: Props) => { serverId: data.serverId, registryId: registryId || "", }) - .then(async (data) => { + .then(async (_data) => { await utils.registry.all.invalidate(); toast.success(registryId ? "Registry updated" : "Registry added"); setIsOpen(false); diff --git a/apps/dokploy/components/dashboard/settings/git/bitbucket/add-bitbucket-provider.tsx b/apps/dokploy/components/dashboard/settings/git/bitbucket/add-bitbucket-provider.tsx index 2c0f30466..0df2d0610 100644 --- a/apps/dokploy/components/dashboard/settings/git/bitbucket/add-bitbucket-provider.tsx +++ b/apps/dokploy/components/dashboard/settings/git/bitbucket/add-bitbucket-provider.tsx @@ -47,10 +47,10 @@ type Schema = z.infer; export const AddBitbucketProvider = () => { const utils = api.useUtils(); const [isOpen, setIsOpen] = useState(false); - const url = useUrl(); + const _url = useUrl(); const { mutateAsync, error, isError } = api.bitbucket.create.useMutation(); const { data: auth } = api.user.get.useQuery(); - const router = useRouter(); + const _router = useRouter(); const form = useForm({ defaultValues: { username: "", diff --git a/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx b/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx index 3343409fe..451ea5d17 100644 --- a/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx +++ b/apps/dokploy/components/dashboard/settings/git/show-git-providers.tsx @@ -102,7 +102,7 @@ export const ShowGitProviders = () => {
- {data?.map((gitProvider, index) => { + {data?.map((gitProvider, _index) => { const isGithub = gitProvider.providerType === "github"; const isGitlab = gitProvider.providerType === "gitlab"; const isBitbucket = diff --git a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx index 6f6d8ff11..d2d3b450d 100644 --- a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx +++ b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx @@ -136,7 +136,7 @@ export const HandleNotifications = ({ notificationId }: Props) => { const [visible, setVisible] = useState(false); const { data: isCloud } = api.settings.isCloud.useQuery(); - const { data: notification, refetch } = api.notification.one.useQuery( + const { data: notification } = api.notification.one.useQuery( { notificationId: notificationId || "", }, @@ -1038,7 +1038,7 @@ export const HandleNotifications = ({ notificationId }: Props) => { }); } toast.success("Connection Success"); - } catch (err) { + } catch (_err) { toast.error("Error testing the provider"); } }} diff --git a/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx index d65069d4b..782b92413 100644 --- a/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx +++ b/apps/dokploy/components/dashboard/settings/notifications/show-notifications.tsx @@ -56,7 +56,7 @@ export const ShowNotifications = () => { ) : (
- {data?.map((notification, index) => ( + {data?.map((notification, _index) => (
{ toast.success("2FA disabled successfully"); utils.auth.get.invalidate(); setIsOpen(false); - } catch (error) { + } catch (_error) { form.setError("password", { message: "Connection error. Please try again.", }); diff --git a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx index 918df4353..3ececb649 100644 --- a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx +++ b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx @@ -47,20 +47,8 @@ const PinSchema = z.object({ type PasswordForm = z.infer; type PinForm = z.infer; -type TwoFactorEnableResponse = { - totpURI: string; - backupCodes: string[]; -}; - -type TwoFactorSetupData = { - qrCodeUrl: string; - secret: string; - totpURI: string; -}; - export const Enable2FA = () => { const utils = api.useUtils(); - const { data: session } = authClient.useSession(); const [data, setData] = useState(null); const [backupCodes, setBackupCodes] = useState([]); const [isDialogOpen, setIsDialogOpen] = useState(false); diff --git a/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx b/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx index f4299709a..761cfb71b 100644 --- a/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx +++ b/apps/dokploy/components/dashboard/settings/profile/profile-form.tsx @@ -54,9 +54,7 @@ const randomImages = [ ]; export const ProfileForm = () => { - const utils = api.useUtils(); - const { mutateAsync: disable2FA, isLoading: isDisabling } = - api.auth.disable2FA.useMutation(); + const _utils = api.useUtils(); const { data, refetch, isLoading } = api.user.get.useQuery(); const { mutateAsync, diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx index cb60effd1..3492ba7c2 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx @@ -26,7 +26,7 @@ export const ShowStorageActions = ({ serverId }: Props) => { isLoading: cleanDockerBuilderIsLoading, } = api.settings.cleanDockerBuilder.useMutation(); - const { mutateAsync: cleanMonitoring, isLoading: cleanMonitoringIsLoading } = + const { mutateAsync: cleanMonitoring } = api.settings.cleanMonitoring.useMutation(); const { mutateAsync: cleanUnusedImages, diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/toggle-docker-cleanup.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/toggle-docker-cleanup.tsx index e574593d5..12e279423 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/toggle-docker-cleanup.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/toggle-docker-cleanup.tsx @@ -36,7 +36,7 @@ export const ToggleDockerCleanup = ({ serverId }: Props) => { await refetch(); } toast.success("Docker Cleanup updated"); - } catch (error) { + } catch (_error) { toast.error("Docker Cleanup Error"); } }; diff --git a/apps/dokploy/components/dashboard/settings/servers/edit-script.tsx b/apps/dokploy/components/dashboard/settings/servers/edit-script.tsx index 0a22220ed..6225ee771 100644 --- a/apps/dokploy/components/dashboard/settings/servers/edit-script.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/edit-script.tsx @@ -82,7 +82,7 @@ export const EditScript = ({ serverId }: Props) => { command: formData.command || "", serverId, }) - .then((data) => { + .then((_data) => { toast.success("Script modified successfully"); }) .catch(() => { diff --git a/apps/dokploy/components/dashboard/settings/servers/gpu-support.tsx b/apps/dokploy/components/dashboard/settings/servers/gpu-support.tsx index ec60fed6d..c24440a61 100644 --- a/apps/dokploy/components/dashboard/settings/servers/gpu-support.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/gpu-support.tsx @@ -56,7 +56,7 @@ export function GPUSupport({ serverId }: GPUSupportProps) { try { await utils.settings.checkGPUStatus.invalidate({ serverId }); await refetch(); - } catch (error) { + } catch (_error) { toast.error("Failed to refresh GPU status"); } finally { setIsRefreshing(false); @@ -74,7 +74,7 @@ export function GPUSupport({ serverId }: GPUSupportProps) { try { await setupGPU.mutateAsync({ serverId }); - } catch (error) { + } catch (_error) { // Error handling is done in mutation's onError } }; diff --git a/apps/dokploy/components/dashboard/settings/servers/handle-servers.tsx b/apps/dokploy/components/dashboard/settings/servers/handle-servers.tsx index be71d8367..979941458 100644 --- a/apps/dokploy/components/dashboard/settings/servers/handle-servers.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/handle-servers.tsx @@ -118,7 +118,7 @@ export const HandleServers = ({ serverId }: Props) => { sshKeyId: data.sshKeyId || "", serverId: serverId || "", }) - .then(async (data) => { + .then(async (_data) => { await utils.server.all.invalidate(); refetchServer(); toast.success(serverId ? "Server Updated" : "Server Created"); diff --git a/apps/dokploy/components/dashboard/settings/servers/security-audit.tsx b/apps/dokploy/components/dashboard/settings/servers/security-audit.tsx index 475f2b8ff..5f693707f 100644 --- a/apps/dokploy/components/dashboard/settings/servers/security-audit.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/security-audit.tsx @@ -25,7 +25,7 @@ export const SecurityAudit = ({ serverId }: Props) => { enabled: !!serverId, }, ); - const utils = api.useUtils(); + const _utils = api.useUtils(); return (
diff --git a/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx b/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx index 23173047e..b8c699268 100644 --- a/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx @@ -80,7 +80,7 @@ const Schema = z.object({ type Schema = z.infer; export const SetupMonitoring = ({ serverId }: Props) => { - const { data, isLoading } = serverId + const { data } = serverId ? api.server.one.useQuery( { serverId: serverId || "", diff --git a/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx b/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx index db4f17b76..0632b97c2 100644 --- a/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/validate-server.tsx @@ -25,7 +25,7 @@ export const ValidateServer = ({ serverId }: Props) => { enabled: !!serverId, }, ); - const utils = api.useUtils(); + const _utils = api.useUtils(); return (
diff --git a/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx b/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx index a025ad379..24d01553b 100644 --- a/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/create-server.tsx @@ -52,10 +52,10 @@ interface Props { export const CreateServer = ({ stepper }: Props) => { const { data: sshKeys } = api.sshKey.all.useQuery(); - const [isOpen, setIsOpen] = useState(false); + const [isOpen, _setIsOpen] = useState(false); const { data: canCreateMoreServers, refetch } = api.stripe.canCreateMoreServers.useQuery(); - const { mutateAsync, error, isError } = api.server.create.useMutation(); + const { mutateAsync } = api.server.create.useMutation(); const cloudSSHKey = sshKeys?.find( (sshKey) => sshKey.name === "dokploy-cloud-ssh-key", ); @@ -96,7 +96,7 @@ export const CreateServer = ({ stepper }: Props) => { username: data.username || "root", sshKeyId: data.sshKeyId || "", }) - .then(async (data) => { + .then(async (_data) => { toast.success("Server Created"); stepper.next(); }) diff --git a/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/verify.tsx b/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/verify.tsx index fe8c36c2c..f7c2a987c 100644 --- a/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/verify.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/welcome-stripe/verify.tsx @@ -37,15 +37,6 @@ export const Verify = () => { ); const [isRefreshing, setIsRefreshing] = useState(false); - const { data: server } = api.server.one.useQuery( - { - serverId, - }, - { - enabled: !!serverId, - }, - ); - return (
diff --git a/apps/dokploy/components/dashboard/settings/users/show-invitations.tsx b/apps/dokploy/components/dashboard/settings/users/show-invitations.tsx index 12670c280..1bf7aa086 100644 --- a/apps/dokploy/components/dashboard/settings/users/show-invitations.tsx +++ b/apps/dokploy/components/dashboard/settings/users/show-invitations.tsx @@ -143,7 +143,7 @@ export const ShowInvitations = () => { {invitation.status === "pending" && ( { + onSelect={(_e) => { copy( `${origin}/invitation?token=${invitation.id}`, ); @@ -159,7 +159,7 @@ export const ShowInvitations = () => { {invitation.status === "pending" && ( { + onSelect={async (_e) => { const result = await authClient.organization.cancelInvitation( { diff --git a/apps/dokploy/components/dashboard/settings/users/show-users.tsx b/apps/dokploy/components/dashboard/settings/users/show-users.tsx index ff56698e4..6847558b7 100644 --- a/apps/dokploy/components/dashboard/settings/users/show-users.tsx +++ b/apps/dokploy/components/dashboard/settings/users/show-users.tsx @@ -35,7 +35,7 @@ import { AddUserPermissions } from "./add-permissions"; export const ShowUsers = () => { const { data: isCloud } = api.settings.isCloud.useQuery(); const { data, isLoading, refetch } = api.user.all.useQuery(); - const { mutateAsync, isLoading: isRemoving } = api.user.remove.useMutation(); + const { mutateAsync } = api.user.remove.useMutation(); return (
diff --git a/apps/dokploy/components/dashboard/settings/web-server.tsx b/apps/dokploy/components/dashboard/settings/web-server.tsx index 326cb0eaf..64b6d634e 100644 --- a/apps/dokploy/components/dashboard/settings/web-server.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server.tsx @@ -14,10 +14,7 @@ import { ShowTraefikActions } from "./servers/actions/show-traefik-actions"; import { ToggleDockerCleanup } from "./servers/actions/toggle-docker-cleanup"; import { UpdateServer } from "./web-server/update-server"; -interface Props { - className?: string; -} -export const WebServer = ({ className }: Props) => { +export const WebServer = () => { const { t } = useTranslation("settings"); const { data } = api.user.get.useQuery(); diff --git a/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx b/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx index a30823363..a6958b16f 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/manage-traefik-ports.tsx @@ -99,7 +99,7 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => { }); toast.success(t("settings.server.webServer.traefik.portsUpdated")); setOpen(false); - } catch (error) { + } catch (_error) { toast.error(t("settings.server.webServer.traefik.portsUpdateError")); } }; diff --git a/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx b/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx index d6e7345e1..3a511d8ea 100644 --- a/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server/update-server-ip.tsx @@ -43,7 +43,7 @@ interface Props { serverId?: string; } -export const UpdateServerIp = ({ children, serverId }: Props) => { +export const UpdateServerIp = ({ children }: Props) => { const [isOpen, setIsOpen] = useState(false); const { data } = api.user.get.useQuery(); diff --git a/apps/dokploy/components/dashboard/swarm/applications/columns.tsx b/apps/dokploy/components/dashboard/swarm/applications/columns.tsx index ab058e851..5ae091a95 100644 --- a/apps/dokploy/components/dashboard/swarm/applications/columns.tsx +++ b/apps/dokploy/components/dashboard/swarm/applications/columns.tsx @@ -214,7 +214,7 @@ export const columns: ColumnDef[] = [ { accessorKey: "Logs", accessorFn: (row) => row.Error, - header: ({ column }) => { + header: () => { return Logs; }, cell: ({ row }) => { diff --git a/apps/dokploy/components/dashboard/swarm/applications/data-table.tsx b/apps/dokploy/components/dashboard/swarm/applications/data-table.tsx index 03915c19b..96f43e617 100644 --- a/apps/dokploy/components/dashboard/swarm/applications/data-table.tsx +++ b/apps/dokploy/components/dashboard/swarm/applications/data-table.tsx @@ -48,7 +48,7 @@ export function DataTable({ const [columnVisibility, setColumnVisibility] = React.useState({}); const [rowSelection, setRowSelection] = React.useState({}); - const [pagination, setPagination] = React.useState({ + const [_pagination, _setPagination] = React.useState({ pageIndex: 0, //initial page index pageSize: 8, //default page size }); diff --git a/apps/dokploy/components/dashboard/swarm/details/show-node-config.tsx b/apps/dokploy/components/dashboard/swarm/details/show-node-config.tsx index a41c5a497..7f27fe3bf 100644 --- a/apps/dokploy/components/dashboard/swarm/details/show-node-config.tsx +++ b/apps/dokploy/components/dashboard/swarm/details/show-node-config.tsx @@ -17,7 +17,7 @@ interface Props { } export const ShowNodeConfig = ({ nodeId, serverId }: Props) => { - const { data, isLoading } = api.swarm.getNodeInfo.useQuery({ + const { data } = api.swarm.getNodeInfo.useQuery({ nodeId, serverId, }); diff --git a/apps/dokploy/components/layouts/side.tsx b/apps/dokploy/components/layouts/side.tsx index 939d10841..63155f8eb 100644 --- a/apps/dokploy/components/layouts/side.tsx +++ b/apps/dokploy/components/layouts/side.tsx @@ -157,7 +157,7 @@ const MENU: Menu = { url: "/dashboard/monitoring", icon: BarChartHorizontalBigIcon, // Only enabled in non-cloud environments - isEnabled: ({ auth, isCloud }) => !isCloud, + isEnabled: ({ isCloud }) => !isCloud, }, { isSingle: true, @@ -277,7 +277,7 @@ const MENU: Menu = { url: "/dashboard/settings/servers", icon: Server, // Only enabled for admins - isEnabled: ({ auth, isCloud }) => !!(auth?.role === "owner"), + isEnabled: ({ auth }) => !!(auth?.role === "owner"), }, { isSingle: true, @@ -490,8 +490,9 @@ function SidebarLogo() { const { state } = useSidebar(); const { data: isCloud } = api.settings.isCloud.useQuery(); const { data: user } = api.user.get.useQuery(); - const { data: dokployVersion } = api.settings.getDokployVersion.useQuery(); + // const { data: dokployVersion } = api.settings.getDokployVersion.useQuery(); const { data: session } = authClient.useSession(); + const { data: organizations, refetch, @@ -501,12 +502,12 @@ function SidebarLogo() { api.organization.delete.useMutation(); const { isMobile } = useSidebar(); const { data: activeOrganization } = authClient.useActiveOrganization(); - const utils = api.useUtils(); + const _utils = api.useUtils(); const { data: invitations, refetch: refetchInvitations } = api.user.getInvitations.useQuery(); - const [activeTeam, setActiveTeam] = useState< + const [_activeTeam, setActiveTeam] = useState< typeof activeOrganization | null >(null); @@ -543,7 +544,7 @@ function SidebarLogo() {

- {activeOrganization?.name} + {activeOrganization?.name ?? "Select Organization"}

@@ -551,7 +552,7 @@ function SidebarLogo() { +
{org.name}
- {org.name} - {(org.ownerId === session?.user?.id || isCloud) && ( + {org.ownerId === session?.user?.id && (
))} - {!isCloud && user?.role === "owner" && ( + {(user?.role === "owner" || isCloud) && ( <> @@ -721,11 +722,11 @@ export default function Page({ children }: Props) { const router = useRouter(); const pathname = usePathname(); - const currentPath = router.pathname; + const _currentPath = router.pathname; const { data: auth } = api.user.get.useQuery(); const includesProjects = pathname?.includes("/dashboard/project"); - const { data: isCloud, isLoading } = api.settings.isCloud.useQuery(); + const { data: isCloud } = api.settings.isCloud.useQuery(); const { home: filteredHome, diff --git a/apps/dokploy/components/layouts/update-server.tsx b/apps/dokploy/components/layouts/update-server.tsx index fa748f849..5d7978859 100644 --- a/apps/dokploy/components/layouts/update-server.tsx +++ b/apps/dokploy/components/layouts/update-server.tsx @@ -11,7 +11,7 @@ export const UpdateServerButton = () => { latestVersion: null, updateAvailable: false, }); - const router = useRouter(); + const _router = useRouter(); const { data: isCloud } = api.settings.isCloud.useQuery(); const { mutateAsync: getUpdateData } = api.settings.getUpdateData.useMutation(); diff --git a/apps/dokploy/components/layouts/user-nav.tsx b/apps/dokploy/components/layouts/user-nav.tsx index 196f6d77d..4a9624de4 100644 --- a/apps/dokploy/components/layouts/user-nav.tsx +++ b/apps/dokploy/components/layouts/user-nav.tsx @@ -24,7 +24,7 @@ import { useRouter } from "next/router"; import { ModeToggle } from "../ui/modeToggle"; import { SidebarMenuButton } from "../ui/sidebar"; -const AUTO_CHECK_UPDATES_INTERVAL_MINUTES = 7; +const _AUTO_CHECK_UPDATES_INTERVAL_MINUTES = 7; export const UserNav = () => { const router = useRouter(); diff --git a/apps/dokploy/components/shared/breadcrumb-sidebar.tsx b/apps/dokploy/components/shared/breadcrumb-sidebar.tsx index 60730c96b..74e9fdf63 100644 --- a/apps/dokploy/components/shared/breadcrumb-sidebar.tsx +++ b/apps/dokploy/components/shared/breadcrumb-sidebar.tsx @@ -26,7 +26,7 @@ export const BreadcrumbSidebar = ({ list }: Props) => { - {list.map((item, index) => ( + {list.map((item, _index) => ( diff --git a/apps/dokploy/components/shared/drawer-logs.tsx b/apps/dokploy/components/shared/drawer-logs.tsx index 5e4ab554b..d8d1affb7 100644 --- a/apps/dokploy/components/shared/drawer-logs.tsx +++ b/apps/dokploy/components/shared/drawer-logs.tsx @@ -43,7 +43,7 @@ export const DrawerLogs = ({ isOpen, onClose, filteredLogs }: Props) => { return ( { + onOpenChange={(_open) => { onClose(); }} > diff --git a/apps/dokploy/components/ui/file-tree.tsx b/apps/dokploy/components/ui/file-tree.tsx index 9db3786e6..0f50d5089 100644 --- a/apps/dokploy/components/ui/file-tree.tsx +++ b/apps/dokploy/components/ui/file-tree.tsx @@ -85,7 +85,7 @@ const Tree = React.forwardRef( return ids; }, [data, initialSlelectedItemId]); - const { ref: refRoot, width, height } = useResizeObserver(); + const { ref: refRoot } = useResizeObserver(); return (
diff --git a/apps/dokploy/migrate.ts b/apps/dokploy/migrate.ts index febd1c0e2..097459b96 100644 --- a/apps/dokploy/migrate.ts +++ b/apps/dokploy/migrate.ts @@ -136,7 +136,7 @@ await db }, }); for (const project of projects) { - const user = await db.update(schema.projects).set({ + const _user = await db.update(schema.projects).set({ organizationId: project.user.organizations[0]?.id || "", }); } diff --git a/apps/dokploy/pages/_error.tsx b/apps/dokploy/pages/_error.tsx index 958e17407..d28e2cb00 100644 --- a/apps/dokploy/pages/_error.tsx +++ b/apps/dokploy/pages/_error.tsx @@ -90,7 +90,7 @@ export default function Custom404({ statusCode, error }: Props) { } // @ts-ignore -Error.getInitialProps = ({ res, err, ...rest }: NextPageContext) => { +Error.getInitialProps = ({ res, err }: NextPageContext) => { const statusCode = res ? res.statusCode : err ? err.statusCode : 404; return { statusCode, error: err }; }; diff --git a/apps/dokploy/pages/api/health.ts b/apps/dokploy/pages/api/health.ts index 9dc8101e5..57875a192 100644 --- a/apps/dokploy/pages/api/health.ts +++ b/apps/dokploy/pages/api/health.ts @@ -1,7 +1,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; export default async function handler( - req: NextApiRequest, + _req: NextApiRequest, res: NextApiResponse, ) { return res.status(200).json({ ok: true }); diff --git a/apps/dokploy/pages/api/providers/github/setup.ts b/apps/dokploy/pages/api/providers/github/setup.ts index ac5e7a6b0..327122509 100644 --- a/apps/dokploy/pages/api/providers/github/setup.ts +++ b/apps/dokploy/pages/api/providers/github/setup.ts @@ -16,8 +16,7 @@ export default async function handler( req: NextApiRequest, res: NextApiResponse, ) { - const { code, state, installation_id, setup_action }: Query = - req.query as Query; + const { code, state, installation_id }: Query = req.query as Query; if (!code) { return res.status(400).json({ error: "Missing code parameter" }); diff --git a/apps/dokploy/pages/api/stripe/webhook.ts b/apps/dokploy/pages/api/stripe/webhook.ts index 6200a79ec..592803b15 100644 --- a/apps/dokploy/pages/api/stripe/webhook.ts +++ b/apps/dokploy/pages/api/stripe/webhook.ts @@ -1,7 +1,7 @@ import { buffer } from "node:stream/consumers"; import { db } from "@/server/db"; -import { server, users_temp } from "@/server/db/schema"; -import { findUserById } from "@dokploy/server"; +import { organization, server, users_temp } from "@/server/db/schema"; +import { findUserById, type Server } from "@dokploy/server"; import { asc, eq } from "drizzle-orm"; import type { NextApiRequest, NextApiResponse } from "next"; import Stripe from "stripe"; @@ -172,11 +172,11 @@ export default async function handler( } await db - .update(admins) + .update(users_temp) .set({ serversQuantity: suscription?.items?.data?.[0]?.quantity ?? 0, }) - .where(eq(admins.stripeCustomerId, suscription.customer as string)); + .where(eq(users_temp.stripeCustomerId, suscription.customer as string)); const admin = await findUserByStripeCustomerId( suscription.customer as string, @@ -205,11 +205,13 @@ export default async function handler( return res.status(400).send("Webhook Error: Admin not found"); } await db - .update(admins) + .update(users_temp) .set({ serversQuantity: 0, }) - .where(eq(admins.stripeCustomerId, newInvoice.customer as string)); + .where( + eq(users_temp.stripeCustomerId, newInvoice.customer as string), + ); await disableServers(admin.id); } @@ -245,12 +247,18 @@ export default async function handler( } const disableServers = async (userId: string) => { - await db - .update(server) - .set({ - serverStatus: "inactive", - }) - .where(eq(server.userId, userId)); + const organizations = await db.query.organization.findMany({ + where: eq(organization.ownerId, userId), + }); + + for (const org of organizations) { + await db + .update(server) + .set({ + serverStatus: "inactive", + }) + .where(eq(server.organizationId, org.id)); + } }; const findUserByStripeCustomerId = async (stripeCustomerId: string) => { @@ -275,11 +283,19 @@ const deactivateServer = async (serverId: string) => { }; export const findServersByUserIdSorted = async (userId: string) => { - const servers = await db.query.server.findMany({ - where: eq(server.userId, userId), - orderBy: asc(server.createdAt), + const organizations = await db.query.organization.findMany({ + where: eq(organization.ownerId, userId), }); + const servers: Server[] = []; + for (const org of organizations) { + const serversByOrg = await db.query.server.findMany({ + where: eq(server.organizationId, org.id), + orderBy: asc(server.createdAt), + }); + servers.push(...serversByOrg); + } + return servers; }; export const updateServersBasedOnQuantity = async ( diff --git a/apps/dokploy/pages/dashboard/docker.tsx b/apps/dokploy/pages/dashboard/docker.tsx index a9d80353f..e01a763be 100644 --- a/apps/dokploy/pages/dashboard/docker.tsx +++ b/apps/dokploy/pages/dashboard/docker.tsx @@ -72,7 +72,7 @@ export async function getServerSideProps( trpcState: helpers.dehydrate(), }, }; - } catch (error) { + } catch (_error) { return { props: {}, }; diff --git a/apps/dokploy/pages/dashboard/monitoring.tsx b/apps/dokploy/pages/dashboard/monitoring.tsx index 4d8b072f5..4272c4536 100644 --- a/apps/dokploy/pages/dashboard/monitoring.tsx +++ b/apps/dokploy/pages/dashboard/monitoring.tsx @@ -15,8 +15,7 @@ const BASE_URL = "http://localhost:3001/metrics"; const DEFAULT_TOKEN = "metrics"; const Dashboard = () => { - const { data: isCloud } = api.settings.isCloud.useQuery(); - const [toggleMonitoring, setToggleMonitoring] = useLocalStorage( + const [toggleMonitoring, _setToggleMonitoring] = useLocalStorage( "monitoring-enabled", false, ); diff --git a/apps/dokploy/pages/dashboard/project/[projectId].tsx b/apps/dokploy/pages/dashboard/project/[projectId].tsx index f85aa9ee8..62de98c13 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId].tsx @@ -261,7 +261,7 @@ const Project = ( try { await composeActions.start.mutateAsync({ composeId: serviceId }); success++; - } catch (error) { + } catch (_error) { toast.error(`Error starting service ${serviceId}`); } } @@ -281,7 +281,7 @@ const Project = ( try { await composeActions.stop.mutateAsync({ composeId: serviceId }); success++; - } catch (error) { + } catch (_error) { toast.error(`Error stopping service ${serviceId}`); } } @@ -685,7 +685,7 @@ export async function getServerSideProps( projectId: params?.projectId, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx index 59dba68ce..94b8f5f5d 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx @@ -65,7 +65,7 @@ type TabState = const Service = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { applicationId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; @@ -86,7 +86,6 @@ const Service = ( const { data: isCloud } = api.settings.isCloud.useQuery(); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); return (
@@ -399,7 +398,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx index c1331e23f..46b727d2a 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx @@ -59,7 +59,7 @@ type TabState = const Service = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { composeId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; @@ -79,7 +79,6 @@ const Service = ( ); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); return ( @@ -393,7 +392,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx index 033b88a9d..e91e0978d 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx @@ -52,7 +52,7 @@ type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced"; const Mariadb = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { mariadbId, activeTab } = props; const router = useRouter(); @@ -60,7 +60,6 @@ const Mariadb = ( const [tab, setSab] = useState(activeTab); const { data } = api.mariadb.one.useQuery({ mariadbId }); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); @@ -342,7 +341,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx index dea8cd57b..b10b7b93d 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx @@ -52,7 +52,7 @@ type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced"; const Mongo = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { mongoId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; @@ -60,7 +60,6 @@ const Mongo = ( const { data } = api.mongo.one.useQuery({ mongoId }); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); @@ -343,7 +342,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx index cc4eb4aa3..261a2762b 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx @@ -52,14 +52,13 @@ type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced"; const MySql = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { mysqlId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; const [tab, setSab] = useState(activeTab); const { data } = api.mysql.one.useQuery({ mysqlId }); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); @@ -348,7 +347,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx index d0f1dc106..5d8fd3b1b 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx @@ -52,7 +52,7 @@ type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced"; const Postgresql = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { postgresId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; @@ -60,7 +60,6 @@ const Postgresql = ( const { data } = api.postgres.one.useQuery({ postgresId }); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); return ( @@ -345,7 +344,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx index 2b053df47..c4f40281f 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx @@ -51,7 +51,7 @@ type TabState = "projects" | "monitoring" | "settings" | "advanced"; const Redis = ( props: InferGetServerSidePropsType, ) => { - const [toggleMonitoring, setToggleMonitoring] = useState(false); + const [_toggleMonitoring, _setToggleMonitoring] = useState(false); const { redisId, activeTab } = props; const router = useRouter(); const { projectId } = router.query; @@ -59,7 +59,6 @@ const Redis = ( const { data } = api.redis.one.useQuery({ redisId }); const { data: auth } = api.user.get.useQuery(); - const { data: monitoring } = api.user.getMetricsToken.useQuery(); const { data: isCloud } = api.settings.isCloud.useQuery(); @@ -335,7 +334,7 @@ export async function getServerSideProps( activeTab: (activeTab || "general") as TabState, }, }; - } catch (error) { + } catch (_error) { return { redirect: { permanent: false, diff --git a/apps/dokploy/pages/dashboard/settings/git-providers.tsx b/apps/dokploy/pages/dashboard/settings/git-providers.tsx index 4187a0ef7..ce2adc9ce 100644 --- a/apps/dokploy/pages/dashboard/settings/git-providers.tsx +++ b/apps/dokploy/pages/dashboard/settings/git-providers.tsx @@ -68,7 +68,7 @@ export async function getServerSideProps( trpcState: helpers.dehydrate(), }, }; - } catch (error) { + } catch (_error) { return { props: {}, }; diff --git a/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx b/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx index 738c647d4..2472feab4 100644 --- a/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx +++ b/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx @@ -33,7 +33,7 @@ export async function getServerSideProps( }, }; } - const { req, res, resolvedUrl } = ctx; + const { req, res } = ctx; const helpers = createServerSideHelpers({ router: appRouter, ctx: { @@ -69,7 +69,7 @@ export async function getServerSideProps( trpcState: helpers.dehydrate(), }, }; - } catch (error) { + } catch (_error) { return { props: {}, }; diff --git a/apps/dokploy/pages/dashboard/swarm.tsx b/apps/dokploy/pages/dashboard/swarm.tsx index c693fd8cf..155531160 100644 --- a/apps/dokploy/pages/dashboard/swarm.tsx +++ b/apps/dokploy/pages/dashboard/swarm.tsx @@ -72,7 +72,7 @@ export async function getServerSideProps( trpcState: helpers.dehydrate(), }, }; - } catch (error) { + } catch (_error) { return { props: {}, }; diff --git a/apps/dokploy/pages/dashboard/traefik.tsx b/apps/dokploy/pages/dashboard/traefik.tsx index 90359ccd6..ce8208beb 100644 --- a/apps/dokploy/pages/dashboard/traefik.tsx +++ b/apps/dokploy/pages/dashboard/traefik.tsx @@ -72,7 +72,7 @@ export async function getServerSideProps( trpcState: helpers.dehydrate(), }, }; - } catch (error) { + } catch (_error) { return { props: {}, }; diff --git a/apps/dokploy/pages/index.tsx b/apps/dokploy/pages/index.tsx index c910e78ec..783ec651d 100644 --- a/apps/dokploy/pages/index.tsx +++ b/apps/dokploy/pages/index.tsx @@ -43,18 +43,11 @@ const LoginSchema = z.object({ password: z.string().min(8), }); -const TwoFactorSchema = z.object({ +const _TwoFactorSchema = z.object({ code: z.string().min(6), }); -const BackupCodeSchema = z.object({ - code: z.string().min(8, { - message: "Backup code must be at least 8 characters", - }), -}); - type LoginForm = z.infer; -type BackupCodeForm = z.infer; interface Props { IS_CLOUD: boolean; @@ -101,7 +94,7 @@ export default function Home({ IS_CLOUD }: Props) { toast.success("Logged in successfully"); router.push("/dashboard/projects"); - } catch (error) { + } catch (_error) { toast.error("An error occurred while logging in"); } finally { setIsLoginLoading(false); @@ -117,7 +110,7 @@ export default function Home({ IS_CLOUD }: Props) { setIsTwoFactorLoading(true); try { - const { data, error } = await authClient.twoFactor.verifyTotp({ + const { error } = await authClient.twoFactor.verifyTotp({ code: twoFactorCode.replace(/\s/g, ""), }); @@ -129,7 +122,7 @@ export default function Home({ IS_CLOUD }: Props) { toast.success("Logged in successfully"); router.push("/dashboard/projects"); - } catch (error) { + } catch (_error) { toast.error("An error occurred while verifying 2FA code"); } finally { setIsTwoFactorLoading(false); @@ -145,7 +138,7 @@ export default function Home({ IS_CLOUD }: Props) { setIsBackupCodeLoading(true); try { - const { data, error } = await authClient.twoFactor.verifyBackupCode({ + const { error } = await authClient.twoFactor.verifyBackupCode({ code: backupCode.trim(), }); @@ -159,7 +152,7 @@ export default function Home({ IS_CLOUD }: Props) { toast.success("Logged in successfully"); router.push("/dashboard/projects"); - } catch (error) { + } catch (_error) { toast.error("An error occurred while verifying backup code"); } finally { setIsBackupCodeLoading(false); @@ -396,7 +389,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { }, }; } - } catch (error) {} + } catch (_error) {} return { props: { diff --git a/apps/dokploy/pages/invitation.tsx b/apps/dokploy/pages/invitation.tsx index 91ca1d0d7..813ec74cc 100644 --- a/apps/dokploy/pages/invitation.tsx +++ b/apps/dokploy/pages/invitation.tsx @@ -16,7 +16,6 @@ import { authClient } from "@/lib/auth-client"; import { api } from "@/utils/api"; import { IS_CLOUD, getUserByToken } from "@dokploy/server"; import { zodResolver } from "@hookform/resolvers/zod"; -import { AlertTriangle } from "lucide-react"; import type { GetServerSidePropsContext } from "next"; import Link from "next/link"; import { useRouter } from "next/router"; @@ -90,9 +89,6 @@ const Invitation = ({ }, ); - const { mutateAsync, error, isError, isSuccess } = - api.auth.createUser.useMutation(); - const form = useForm({ defaultValues: { name: "", @@ -115,7 +111,7 @@ const Invitation = ({ const onSubmit = async (values: Register) => { try { - const { data, error } = await authClient.signUp.email({ + const { error } = await authClient.signUp.email({ email: values.email, password: values.password, name: values.name, @@ -131,13 +127,13 @@ const Invitation = ({ return; } - const result = await authClient.organization.acceptInvitation({ + const _result = await authClient.organization.acceptInvitation({ invitationId: token, }); toast.success("Account created successfully"); router.push("/dashboard/projects"); - } catch (error) { + } catch (_error) { toast.error("An error occurred while creating your account"); } }; @@ -180,14 +176,14 @@ const Invitation = ({
- {isError && ( + {/* {isError && (
{error?.message}
- )} + )} */}
@@ -313,7 +309,6 @@ export async function getServerSideProps(ctx: GetServerSidePropsContext) { const { query } = ctx; const token = query.token; - console.log("query", query); if (typeof token !== "string") { return { diff --git a/apps/dokploy/pages/register.tsx b/apps/dokploy/pages/register.tsx index 701d8f5b5..980f641f6 100644 --- a/apps/dokploy/pages/register.tsx +++ b/apps/dokploy/pages/register.tsx @@ -13,15 +13,15 @@ import { } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { authClient } from "@/lib/auth-client"; -import { api } from "@/utils/api"; import { IS_CLOUD, isAdminPresent, validateRequest } from "@dokploy/server"; import { zodResolver } from "@hookform/resolvers/zod"; import { AlertTriangle } from "lucide-react"; import type { GetServerSidePropsContext } from "next"; import Link from "next/link"; import { useRouter } from "next/router"; -import { type ReactElement, useEffect } from "react"; +import { type ReactElement, useEffect, useState } from "react"; import { useForm } from "react-hook-form"; +import { toast } from "sonner"; import { z } from "zod"; const registerSchema = z @@ -72,15 +72,16 @@ interface Props { const Register = ({ isCloud }: Props) => { const router = useRouter(); - const { mutateAsync, error, isError, data } = - api.auth.createAdmin.useMutation(); + const [isError, setIsError] = useState(false); + const [error, setError] = useState(null); + const [data, setData] = useState(null); const form = useForm({ defaultValues: { name: "Mauricio Siu", email: "user5@yopmail.com", - password: "Password1234", - confirmPassword: "Password1234", + password: "Password123", + confirmPassword: "Password123", }, resolver: zodResolver(registerSchema), }); @@ -96,27 +97,19 @@ const Register = ({ isCloud }: Props) => { name: values.name, }); - // const { data, error } = await authClient.admin.createUser({ - // name: values.name, - // email: values.email, - // password: values.password, - // role: "superAdmin", - // }); - - // consol/e.log(data, error); - // await mutateAsync({ - // email: values.email.toLowerCase(), - // password: values.password, - // }) - // .then(() => { - // toast.success("User registered successfuly", { - // duration: 2000, - // }); - // if (!isCloud) { - // router.push("/"); - // } - // }) - // .catch((e) => e); + if (error) { + setIsError(true); + setError(error.message || "An error occurred"); + } else { + toast.success("User registered successfuly", { + duration: 2000, + }); + if (!isCloud) { + router.push("/"); + } else { + setData(data); + } + } }; return (
@@ -138,15 +131,15 @@ const Register = ({ isCloud }: Props) => {
{isError && ( -
+
- {error?.message} + {error}
)} - {data?.type === "cloud" && ( - + {isCloud && data && ( + Registered successfully, please check your inbox or spam folder to confirm your account. diff --git a/apps/dokploy/pages/reset-password.tsx b/apps/dokploy/pages/reset-password.tsx index 42e2ce002..a34a25ed0 100644 --- a/apps/dokploy/pages/reset-password.tsx +++ b/apps/dokploy/pages/reset-password.tsx @@ -77,7 +77,7 @@ export default function Home({ token }: Props) { resetPasswordToken: token, password: values.password, }) - .then((data) => { + .then((_data) => { toast.success("Password reset successfully", { duration: 2000, }); diff --git a/apps/dokploy/pages/send-reset-password.tsx b/apps/dokploy/pages/send-reset-password.tsx index ce73fbb82..0ea59cf85 100644 --- a/apps/dokploy/pages/send-reset-password.tsx +++ b/apps/dokploy/pages/send-reset-password.tsx @@ -43,13 +43,13 @@ type AuthResponse = { }; export default function Home() { - const [temp, setTemp] = useState({ + const [temp, _setTemp] = useState({ is2FAEnabled: false, authId: "", }); const { mutateAsync, isLoading, isError, error } = api.auth.sendResetPasswordEmail.useMutation(); - const router = useRouter(); + const _router = useRouter(); const form = useForm({ defaultValues: { email: "", @@ -65,7 +65,7 @@ export default function Home() { await mutateAsync({ email: values.email, }) - .then((data) => { + .then((_data) => { toast.success("Email sent", { duration: 2000, }); @@ -150,7 +150,7 @@ export default function Home() { Home.getLayout = (page: ReactElement) => { return {page}; }; -export async function getServerSideProps(context: GetServerSidePropsContext) { +export async function getServerSideProps(_context: GetServerSidePropsContext) { if (!IS_CLOUD) { return { redirect: { diff --git a/apps/dokploy/server/api/routers/auth.ts b/apps/dokploy/server/api/routers/auth.ts index da3121b2e..31a50c67b 100644 --- a/apps/dokploy/server/api/routers/auth.ts +++ b/apps/dokploy/server/api/routers/auth.ts @@ -33,7 +33,7 @@ import { } from "../trpc"; export const authRouter = createTRPCRouter({ - createAdmin: publicProcedure.mutation(async ({ ctx, input }) => { + createAdmin: publicProcedure.mutation(async ({ input }) => { try { if (!IS_CLOUD) { const admin = await db.query.admins.findFirst({}); @@ -72,9 +72,9 @@ export const authRouter = createTRPCRouter({ }); } }), - createUser: publicProcedure.mutation(async ({ ctx, input }) => { + createUser: publicProcedure.mutation(async ({ input }) => { try { - const token = await getUserByToken(input.token); + const _token = await getUserByToken(input.token); // if (token.isExpired) { // throw new TRPCError({ // code: "BAD_REQUEST", @@ -103,7 +103,7 @@ export const authRouter = createTRPCRouter({ } }), - login: publicProcedure.mutation(async ({ ctx, input }) => { + login: publicProcedure.mutation(async ({ input }) => { try { const auth = await findAuthByEmail(input.email); @@ -169,7 +169,7 @@ export const authRouter = createTRPCRouter({ }), logout: protectedProcedure.mutation(async ({ ctx }) => { - const { req, res } = ctx; + const { req } = ctx; const { session } = await validateRequest(req); if (!session) return false; @@ -229,7 +229,7 @@ export const authRouter = createTRPCRouter({ message: "Password is incorrect", }); } - const { req, res } = ctx; + const { req } = ctx; const { session } = await validateRequest(req); if (!session) return false; @@ -245,7 +245,7 @@ export const authRouter = createTRPCRouter({ return true; }), - generateToken: protectedProcedure.mutation(async ({ ctx, input }) => { + generateToken: protectedProcedure.mutation(async ({ ctx }) => { const auth = await findUserById(ctx.user.id); console.log(auth); @@ -276,7 +276,7 @@ export const authRouter = createTRPCRouter({ email: z.string().min(1).email(), }), ) - .mutation(async ({ ctx, input }) => { + .mutation(async ({ input }) => { if (!IS_CLOUD) { throw new TRPCError({ code: "NOT_FOUND", @@ -329,7 +329,7 @@ export const authRouter = createTRPCRouter({ password: z.string().min(1), }), ) - .mutation(async ({ ctx, input }) => { + .mutation(async ({ input }) => { if (!IS_CLOUD) { throw new TRPCError({ code: "NOT_FOUND", @@ -373,7 +373,7 @@ export const authRouter = createTRPCRouter({ confirmationToken: z.string().min(1), }), ) - .mutation(async ({ ctx, input }) => { + .mutation(async ({ input }) => { if (!IS_CLOUD) { throw new TRPCError({ code: "NOT_FOUND", diff --git a/apps/dokploy/server/api/routers/server.ts b/apps/dokploy/server/api/routers/server.ts index 3215226e3..1ebb161a4 100644 --- a/apps/dokploy/server/api/routers/server.ts +++ b/apps/dokploy/server/api/routers/server.ts @@ -12,6 +12,7 @@ import { mariadb, mongo, mysql, + organization, postgres, redis, server, @@ -102,6 +103,18 @@ export const serverRouter = createTRPCRouter({ return result; }), + count: protectedProcedure.query(async ({ ctx }) => { + const organizations = await db.query.organization.findMany({ + where: eq(organization.ownerId, ctx.user.id), + with: { + servers: true, + }, + }); + + const servers = organizations.flatMap((org) => org.servers); + + return servers.length ?? 0; + }), withSSHKey: protectedProcedure.query(async ({ ctx }) => { const result = await db.query.server.findMany({ orderBy: desc(server.createdAt), diff --git a/apps/dokploy/server/api/routers/stripe.ts b/apps/dokploy/server/api/routers/stripe.ts index 0e0e07a47..a226eeac8 100644 --- a/apps/dokploy/server/api/routers/stripe.ts +++ b/apps/dokploy/server/api/routers/stripe.ts @@ -56,7 +56,7 @@ export const stripeRouter = createTRPCRouter({ }); const items = getStripeItems(input.serverQuantity, input.isAnnual); - const user = await findUserById(ctx.user.ownerId); + const user = await findUserById(ctx.user.id); let stripeCustomerId = user.stripeCustomerId; @@ -78,7 +78,7 @@ export const stripeRouter = createTRPCRouter({ customer: stripeCustomerId, }), metadata: { - ownerId: user.id, + adminId: user.id, }, allow_promotion_codes: true, success_url: `${WEBSITE_URL}/dashboard/settings/servers?success=true`, @@ -88,7 +88,7 @@ export const stripeRouter = createTRPCRouter({ return { sessionId: session.id }; }), createCustomerPortalSession: adminProcedure.mutation(async ({ ctx }) => { - const user = await findUserById(ctx.user.ownerId); + const user = await findUserById(ctx.user.id); if (!user.stripeCustomerId) { throw new TRPCError({ diff --git a/apps/dokploy/server/db/seed.ts b/apps/dokploy/server/db/seed.ts index 3216a44b4..5b3eb6c62 100644 --- a/apps/dokploy/server/db/seed.ts +++ b/apps/dokploy/server/db/seed.ts @@ -1,15 +1,10 @@ -import bc from "bcrypt"; import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; const connectionString = process.env.DATABASE_URL!; const pg = postgres(connectionString, { max: 1 }); -const db = drizzle(pg); - -function password(txt: string) { - return bc.hashSync(txt, 10); -} +const _db = drizzle(pg); async function seed() { console.log("> Seed:", process.env.DATABASE_PATH, "\n"); diff --git a/apps/dokploy/server/utils/docker.ts b/apps/dokploy/server/utils/docker.ts index 92008678f..3314eb62e 100644 --- a/apps/dokploy/server/utils/docker.ts +++ b/apps/dokploy/server/utils/docker.ts @@ -6,7 +6,7 @@ export const isWSL = async () => { const { stdout } = await execAsync("uname -r"); const isWSL = stdout.includes("microsoft"); return isWSL; - } catch (error) { + } catch (_error) { return false; } }; diff --git a/apps/dokploy/server/wss/docker-container-terminal.ts b/apps/dokploy/server/wss/docker-container-terminal.ts index 04ef5c96c..2f25edb1a 100644 --- a/apps/dokploy/server/wss/docker-container-terminal.ts +++ b/apps/dokploy/server/wss/docker-container-terminal.ts @@ -50,8 +50,8 @@ export const setupDockerContainerTerminalWebSocketServer = ( throw new Error("No SSH key available for this server"); const conn = new Client(); - let stdout = ""; - let stderr = ""; + let _stdout = ""; + let _stderr = ""; conn .once("ready", () => { conn.exec( @@ -61,16 +61,16 @@ export const setupDockerContainerTerminalWebSocketServer = ( if (err) throw err; stream - .on("close", (code: number, signal: string) => { + .on("close", (code: number, _signal: string) => { ws.send(`\nContainer closed with code: ${code}\n`); conn.end(); }) .on("data", (data: string) => { - stdout += data.toString(); + _stdout += data.toString(); ws.send(data.toString()); }) .stderr.on("data", (data) => { - stderr += data.toString(); + _stderr += data.toString(); ws.send(data.toString()); console.error("Error: ", data.toString()); }); diff --git a/apps/dokploy/server/wss/drawer-logs.ts b/apps/dokploy/server/wss/drawer-logs.ts index 9fe947ffa..404dfeee5 100644 --- a/apps/dokploy/server/wss/drawer-logs.ts +++ b/apps/dokploy/server/wss/drawer-logs.ts @@ -32,7 +32,7 @@ export const setupDrawerLogsWebSocketServer = ( }); wssTerm.on("connection", async (ws, req) => { - const url = new URL(req.url || "", `http://${req.headers.host}`); + const _url = new URL(req.url || "", `http://${req.headers.host}`); const { user, session } = await validateRequest(req); if (!user || !session) { diff --git a/apps/dokploy/server/wss/listen-deployment.ts b/apps/dokploy/server/wss/listen-deployment.ts index ee470fcbf..4a25c6f0e 100644 --- a/apps/dokploy/server/wss/listen-deployment.ts +++ b/apps/dokploy/server/wss/listen-deployment.ts @@ -103,7 +103,7 @@ export const setupDeploymentLogsWebSocketServer = ( ws.close(); }); } - } catch (error) { + } catch (_error) { // @ts-ignore // const errorMessage = error?.message as unknown as string; // ws.send(errorMessage); diff --git a/apps/dokploy/server/wss/terminal.ts b/apps/dokploy/server/wss/terminal.ts index 6e9c3614f..094c5e157 100644 --- a/apps/dokploy/server/wss/terminal.ts +++ b/apps/dokploy/server/wss/terminal.ts @@ -144,8 +144,8 @@ export const setupTerminalWebSocketServer = ( } const conn = new Client(); - let stdout = ""; - let stderr = ""; + let _stdout = ""; + let _stderr = ""; ws.send("Connecting...\n"); @@ -158,16 +158,16 @@ export const setupTerminalWebSocketServer = ( if (err) throw err; stream - .on("close", (code: number, signal: string) => { + .on("close", (code: number, _signal: string) => { ws.send(`\nContainer closed with code: ${code}\n`); conn.end(); }) .on("data", (data: string) => { - stdout += data.toString(); + _stdout += data.toString(); ws.send(data.toString()); }) .stderr.on("data", (data) => { - stderr += data.toString(); + _stderr += data.toString(); ws.send(data.toString()); console.error("Error: ", data.toString()); }); diff --git a/apps/dokploy/templates/appsmith/index.ts b/apps/dokploy/templates/appsmith/index.ts index ff744a249..73279e91b 100644 --- a/apps/dokploy/templates/appsmith/index.ts +++ b/apps/dokploy/templates/appsmith/index.ts @@ -7,7 +7,7 @@ import { } from "../utils"; export function generate(schema: Schema): Template { - const mainServiceHash = generateHash(schema.projectName); + const _mainServiceHash = generateHash(schema.projectName); const domains: DomainSchema[] = [ { diff --git a/apps/dokploy/templates/blender/index.ts b/apps/dokploy/templates/blender/index.ts index 84e527554..79508bed5 100644 --- a/apps/dokploy/templates/blender/index.ts +++ b/apps/dokploy/templates/blender/index.ts @@ -7,7 +7,7 @@ import { } from "../utils"; export function generate(schema: Schema): Template { - const mainServiceHash = generateHash(schema.projectName); + const _mainServiceHash = generateHash(schema.projectName); const mainDomain = generateRandomDomain(schema); const domains: DomainSchema[] = [ diff --git a/apps/dokploy/templates/cloudflared/index.ts b/apps/dokploy/templates/cloudflared/index.ts index 661fa31d0..93ea091c6 100644 --- a/apps/dokploy/templates/cloudflared/index.ts +++ b/apps/dokploy/templates/cloudflared/index.ts @@ -1,6 +1,6 @@ import type { Schema, Template } from "../utils"; -export function generate(schema: Schema): Template { +export function generate(_schema: Schema): Template { const envs = [`CLOUDFLARE_TUNNEL_TOKEN=""`]; return { diff --git a/apps/dokploy/templates/drawio/index.ts b/apps/dokploy/templates/drawio/index.ts index e3c57c5a5..701283c8d 100644 --- a/apps/dokploy/templates/drawio/index.ts +++ b/apps/dokploy/templates/drawio/index.ts @@ -8,7 +8,7 @@ import { export function generate(schema: Schema): Template { const mainDomain = generateRandomDomain(schema); - const secretKeyBase = generateBase64(64); + const _secretKeyBase = generateBase64(64); const domains: DomainSchema[] = [ { diff --git a/apps/dokploy/templates/immich/index.ts b/apps/dokploy/templates/immich/index.ts index b1b11afb1..4beca87da 100644 --- a/apps/dokploy/templates/immich/index.ts +++ b/apps/dokploy/templates/immich/index.ts @@ -11,7 +11,7 @@ export function generate(schema: Schema): Template { const mainDomain = generateRandomDomain(schema); const dbPassword = generatePassword(); const dbUser = "immich"; - const appSecret = generateBase64(32); + const _appSecret = generateBase64(32); const domains: DomainSchema[] = [ { diff --git a/apps/dokploy/templates/unifi/index.ts b/apps/dokploy/templates/unifi/index.ts index 975ce63d9..ea67b0fae 100644 --- a/apps/dokploy/templates/unifi/index.ts +++ b/apps/dokploy/templates/unifi/index.ts @@ -1,6 +1,6 @@ import type { Schema, Template } from "../utils"; -export function generate(schema: Schema): Template { +export function generate(_schema: Schema): Template { const mounts: Template["mounts"] = [ { filePath: "init-mongo.sh", diff --git a/packages/server/src/db/schema/certificate.ts b/packages/server/src/db/schema/certificate.ts index 80d533508..bf72f7db3 100644 --- a/packages/server/src/db/schema/certificate.ts +++ b/packages/server/src/db/schema/certificate.ts @@ -28,19 +28,16 @@ export const certificates = pgTable("certificate", { }), }); -export const certificatesRelations = relations( - certificates, - ({ one, many }) => ({ - server: one(server, { - fields: [certificates.serverId], - references: [server.serverId], - }), - organization: one(organization, { - fields: [certificates.organizationId], - references: [organization.id], - }), +export const certificatesRelations = relations(certificates, ({ one }) => ({ + server: one(server, { + fields: [certificates.serverId], + references: [server.serverId], }), -); + organization: one(organization, { + fields: [certificates.organizationId], + references: [organization.id], + }), +})); export const apiCreateCertificate = createInsertSchema(certificates, { name: z.string().min(1), diff --git a/packages/server/src/db/schema/git-provider.ts b/packages/server/src/db/schema/git-provider.ts index dc88131a9..922307376 100644 --- a/packages/server/src/db/schema/git-provider.ts +++ b/packages/server/src/db/schema/git-provider.ts @@ -29,7 +29,7 @@ export const gitProvider = pgTable("git_provider", { .references(() => organization.id, { onDelete: "cascade" }), }); -export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({ +export const gitProviderRelations = relations(gitProvider, ({ one }) => ({ github: one(github, { fields: [gitProvider.gitProviderId], references: [github.gitProviderId], diff --git a/packages/server/src/db/schema/registry.ts b/packages/server/src/db/schema/registry.ts index 35526f90c..b18747095 100644 --- a/packages/server/src/db/schema/registry.ts +++ b/packages/server/src/db/schema/registry.ts @@ -32,7 +32,7 @@ export const registry = pgTable("registry", { .references(() => organization.id, { onDelete: "cascade" }), }); -export const registryRelations = relations(registry, ({ one, many }) => ({ +export const registryRelations = relations(registry, ({ many }) => ({ applications: many(applications), })); diff --git a/packages/server/src/lib/auth.ts b/packages/server/src/lib/auth.ts index a8d75637b..192f6d0ea 100644 --- a/packages/server/src/lib/auth.ts +++ b/packages/server/src/lib/auth.ts @@ -2,14 +2,12 @@ import type { IncomingMessage } from "node:http"; import * as bcrypt from "bcrypt"; import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; -import { - createAuthMiddleware, - organization, - twoFactor, -} from "better-auth/plugins"; +import { organization, twoFactor } from "better-auth/plugins"; import { and, desc, eq } from "drizzle-orm"; import { db } from "../db"; import * as schema from "../db/schema"; +import { sendVerificationEmail } from "../verification/send-verification-email"; +import { IS_CLOUD } from "../constants"; export const auth = betterAuth({ database: drizzleAdapter(db, { @@ -27,9 +25,18 @@ export const auth = betterAuth({ clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, + emailVerification: { + sendOnSignUp: true, + autoSignInAfterVerification: true, + sendVerificationEmail: async ({ user, url }) => { + console.log("Sending verification email to", user.email); + await sendVerificationEmail(user.email, url); + }, + }, emailAndPassword: { enabled: true, - + autoSignIn: !IS_CLOUD, + requireEmailVerification: IS_CLOUD, password: { async hash(password) { return bcrypt.hashSync(password, 10); @@ -39,33 +46,37 @@ export const auth = betterAuth({ }, }, }, - hooks: { - after: createAuthMiddleware(async (ctx) => { - if (ctx.path.startsWith("/sign-up")) { - const newSession = ctx.context.newSession; - if (ctx.headers?.get("x-dokploy-token")) { - } else { - const organization = await db - .insert(schema.organization) - .values({ - name: "My Organization", - ownerId: newSession?.user?.id || "", - createdAt: new Date(), - }) - .returning() - .then((res) => res[0]); - - await db.insert(schema.member).values({ - userId: newSession?.user?.id || "", - organizationId: organization?.id || "", - role: "owner", - createdAt: new Date(), - }); - } - } - }), - }, databaseHooks: { + user: { + create: { + after: async (user) => { + const isAdminPresent = await db.query.member.findFirst({ + where: eq(schema.member.role, "owner"), + }); + + if (IS_CLOUD || !isAdminPresent) { + await db.transaction(async (tx) => { + const organization = await tx + .insert(schema.organization) + .values({ + name: "My Organization", + ownerId: user.id, + createdAt: new Date(), + }) + .returning() + .then((res) => res[0]); + + await tx.insert(schema.member).values({ + userId: user.id, + organizationId: organization?.id || "", + role: "owner", + createdAt: new Date(), + }); + }); + } + }, + }, + }, session: { create: { before: async (session) => { @@ -106,7 +117,7 @@ export const auth = betterAuth({ plugins: [ twoFactor(), organization({ - async sendInvitationEmail(data, request) { + async sendInvitationEmail(data, _request) { const inviteLink = `https://example.com/accept-invitation/${data.id}`; // https://example.com/accept-invitation/8jlBi9Tb9isDb8mc8Sb85u1BaJYklKB2 // sendOrganizationInvitation({ diff --git a/packages/server/src/lib/crypto.ts b/packages/server/src/lib/crypto.ts deleted file mode 100644 index 27d86dbd5..000000000 --- a/packages/server/src/lib/crypto.ts +++ /dev/null @@ -1,94 +0,0 @@ -// import { -// decodeHex, -// encodeBase32LowerCaseNoPadding, -// encodeHexLowerCase, -// } from "@oslojs/encoding"; -// import { generateRandomString } from "@oslojs/crypto/random"; -// import { constantTimeEqual } from "@oslojs/crypto/subtle"; -// import { scrypt } from "./scrypt/index"; - -// import type { RandomReader } from "@oslojs/crypto/random"; - -// async function generateScryptKey( -// data: string, -// salt: string, -// blockSize = 16, -// ): Promise { -// const encodedData = new TextEncoder().encode(data); -// const encodedSalt = new TextEncoder().encode(salt); -// const keyUint8Array = await scrypt(encodedData, encodedSalt, { -// N: 16384, -// r: blockSize, -// p: 1, -// dkLen: 64, -// }); -// return new Uint8Array(keyUint8Array); -// } - -// const random: RandomReader = { -// read(bytes: Uint8Array): void { -// crypto.getRandomValues(bytes); -// }, -// }; - -// export function generateId(length: number): string { -// const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; -// return generateRandomString(random, alphabet, length); -// } - -// export function generateIdFromEntropySize(size: number): string { -// const buffer = crypto.getRandomValues(new Uint8Array(size)); -// return encodeBase32LowerCaseNoPadding(buffer); -// } - -// export class Scrypt implements PasswordHashingAlgorithm { -// async hash(password: string): Promise { -// const salt = encodeHexLowerCase(crypto.getRandomValues(new Uint8Array(16))); -// const key = await generateScryptKey(password.normalize("NFKC"), salt); -// return `${salt}:${encodeHexLowerCase(key)}`; -// } -// async verify(hash: string, password: string): Promise { -// const parts = hash.split(":"); -// if (parts.length !== 2) return false; - -// const [salt, key] = parts; -// const targetKey = await generateScryptKey(password.normalize("NFKC"), salt); -// return constantTimeEqual(targetKey, decodeHex(key)); -// } -// } - -// export class LegacyScrypt implements PasswordHashingAlgorithm { -// async hash(password: string): Promise { -// const salt = encodeHexLowerCase(crypto.getRandomValues(new Uint8Array(16))); -// const key = await generateScryptKey(password.normalize("NFKC"), salt); -// return `s2:${salt}:${encodeHexLowerCase(key)}`; -// } -// async verify(hash: string, password: string): Promise { -// const parts = hash.split(":"); -// if (parts.length === 2) { -// const [salt, key] = parts; -// const targetKey = await generateScryptKey( -// password.normalize("NFKC"), -// salt, -// 8, -// ); -// const result = constantTimeEqual(targetKey, decodeHex(key)); -// return result; -// } -// if (parts.length !== 3) return false; -// const [version, salt, key] = parts; -// if (version === "s2") { -// const targetKey = await generateScryptKey( -// password.normalize("NFKC"), -// salt, -// ); -// return constantTimeEqual(targetKey, decodeHex(key)); -// } -// return false; -// } -// } - -// export interface PasswordHashingAlgorithm { -// hash(password: string): Promise; -// verify(hash: string, password: string): Promise; -// } diff --git a/packages/server/src/lib/scrypt/index.ts b/packages/server/src/lib/scrypt/index.ts deleted file mode 100644 index 8337712ea..000000000 --- a/packages/server/src/lib/scrypt/index.ts +++ /dev/null @@ -1 +0,0 @@ -// diff --git a/packages/server/src/monitoring/utils.ts b/packages/server/src/monitoring/utils.ts index 561cc8355..147ade0ad 100644 --- a/packages/server/src/monitoring/utils.ts +++ b/packages/server/src/monitoring/utils.ts @@ -73,7 +73,7 @@ export const readStatsFile = async ( const filePath = `${MONITORING_PATH}/${appName}/${statType}.json`; const data = await promises.readFile(filePath, "utf-8"); return JSON.parse(data); - } catch (error) { + } catch (_error) { return []; } }; @@ -108,7 +108,7 @@ export const readLastValueStatsFile = async ( const data = await promises.readFile(filePath, "utf-8"); const stats = JSON.parse(data); return stats[stats.length - 1] || null; - } catch (error) { + } catch (_error) { return null; } }; diff --git a/packages/server/src/services/admin.ts b/packages/server/src/services/admin.ts index 1e2b569f4..78df14aa4 100644 --- a/packages/server/src/services/admin.ts +++ b/packages/server/src/services/admin.ts @@ -12,8 +12,8 @@ import { IS_CLOUD } from "../constants"; export type User = typeof users_temp.$inferSelect; export const createInvitation = async ( - input: typeof apiCreateUserInvitation._type, - adminId: string, + _input: typeof apiCreateUserInvitation._type, + _adminId: string, ) => { // await db.transaction(async (tx) => { // const result = await tx @@ -83,8 +83,8 @@ export const updateUser = async (userId: string, userData: Partial) => { }; export const updateAdminById = async ( - adminId: string, - adminData: Partial, + _adminId: string, + _adminData: Partial, ) => { // const admin = await db // .update(admins) @@ -102,8 +102,6 @@ export const isAdminPresent = async () => { where: eq(member.role, "owner"), }); - console.log("admin", admin); - if (!admin) { return false; } diff --git a/packages/server/src/services/docker.ts b/packages/server/src/services/docker.ts index 597c03fa1..a4a3b0b5e 100644 --- a/packages/server/src/services/docker.ts +++ b/packages/server/src/services/docker.ts @@ -98,7 +98,7 @@ export const getConfig = async ( const config = JSON.parse(stdout); return config; - } catch (error) {} + } catch (_error) {} }; export const getContainersByAppNameMatch = async ( @@ -156,7 +156,7 @@ export const getContainersByAppNameMatch = async ( }); return containers || []; - } catch (error) {} + } catch (_error) {} return []; }; @@ -214,7 +214,7 @@ export const getStackContainersByAppName = async ( }); return containers || []; - } catch (error) {} + } catch (_error) {} return []; }; @@ -274,7 +274,7 @@ export const getServiceContainersByAppName = async ( }); return containers || []; - } catch (error) {} + } catch (_error) {} return []; }; @@ -325,7 +325,7 @@ export const getContainersByAppLabel = async ( }); return containers || []; - } catch (error) {} + } catch (_error) {} return []; }; @@ -344,7 +344,7 @@ export const containerRestart = async (containerId: string) => { const config = JSON.parse(stdout); return config; - } catch (error) {} + } catch (_error) {} }; export const getSwarmNodes = async (serverId?: string) => { @@ -373,7 +373,7 @@ export const getSwarmNodes = async (serverId?: string) => { .split("\n") .map((line) => JSON.parse(line)); return nodesArray; - } catch (error) {} + } catch (_error) {} }; export const getNodeInfo = async (nodeId: string, serverId?: string) => { @@ -399,7 +399,7 @@ export const getNodeInfo = async (nodeId: string, serverId?: string) => { const nodeInfo = JSON.parse(stdout); return nodeInfo; - } catch (error) {} + } catch (_error) {} }; export const getNodeApplications = async (serverId?: string) => { @@ -431,7 +431,7 @@ export const getNodeApplications = async (serverId?: string) => { .filter((service) => !service.Name.startsWith("dokploy-")); return appArray; - } catch (error) {} + } catch (_error) {} }; export const getApplicationInfo = async ( @@ -464,5 +464,5 @@ export const getApplicationInfo = async ( .map((line) => JSON.parse(line)); return appArray; - } catch (error) {} + } catch (_error) {} }; diff --git a/packages/server/src/services/github.ts b/packages/server/src/services/github.ts index deb5f3fa2..19deb2b24 100644 --- a/packages/server/src/services/github.ts +++ b/packages/server/src/services/github.ts @@ -119,7 +119,7 @@ export const issueCommentExists = async ({ comment_id: comment_id, }); return true; - } catch (error) { + } catch (_error) { return false; } }; diff --git a/packages/server/src/services/mount.ts b/packages/server/src/services/mount.ts index 55557ea0e..836feacec 100644 --- a/packages/server/src/services/mount.ts +++ b/packages/server/src/services/mount.ts @@ -211,7 +211,7 @@ export const deleteFileMount = async (mountId: string) => { } else { await removeFileOrDirectory(fullPath); } - } catch (error) {} + } catch (_error) {} }; export const getBaseFilesPath = async (mountId: string) => { diff --git a/packages/server/src/services/preview-deployment.ts b/packages/server/src/services/preview-deployment.ts index 775621773..a1ffca4ba 100644 --- a/packages/server/src/services/preview-deployment.ts +++ b/packages/server/src/services/preview-deployment.ts @@ -103,7 +103,7 @@ export const removePreviewDeployment = async (previewDeploymentId: string) => { for (const operation of cleanupOperations) { try { await operation(); - } catch (error) {} + } catch (_error) {} } return deployment[0]; } catch (error) { diff --git a/packages/server/src/setup/monitoring-setup.ts b/packages/server/src/setup/monitoring-setup.ts index afadb6c10..75b9a928f 100644 --- a/packages/server/src/setup/monitoring-setup.ts +++ b/packages/server/src/setup/monitoring-setup.ts @@ -66,7 +66,7 @@ export const setupMonitoring = async (serverId: string) => { await container.inspect(); await container.remove({ force: true }); console.log("Removed existing container"); - } catch (error) { + } catch (_error) { // Container doesn't exist, continue } @@ -135,7 +135,7 @@ export const setupWebMonitoring = async (userId: string) => { await container.inspect(); await container.remove({ force: true }); console.log("Removed existing container"); - } catch (error) {} + } catch (_error) {} await docker.createContainer(settings); const newContainer = docker.getContainer(containerName); diff --git a/packages/server/src/setup/postgres-setup.ts b/packages/server/src/setup/postgres-setup.ts index b5794c2b2..55361b689 100644 --- a/packages/server/src/setup/postgres-setup.ts +++ b/packages/server/src/setup/postgres-setup.ts @@ -56,7 +56,7 @@ export const initializePostgres = async () => { }); console.log("Postgres Started ✅"); - } catch (error) { + } catch (_error) { await docker.createService(settings); console.log("Postgres Not Found: Starting ✅"); } diff --git a/packages/server/src/setup/redis-setup.ts b/packages/server/src/setup/redis-setup.ts index 1c3b545a5..774e41927 100644 --- a/packages/server/src/setup/redis-setup.ts +++ b/packages/server/src/setup/redis-setup.ts @@ -52,7 +52,7 @@ export const initializeRedis = async () => { ...settings, }); console.log("Redis Started ✅"); - } catch (error) { + } catch (_error) { await docker.createService(settings); console.log("Redis Not Found: Starting ✅"); } diff --git a/packages/server/src/setup/server-audit.ts b/packages/server/src/setup/server-audit.ts index df00e9a74..b9283c313 100644 --- a/packages/server/src/setup/server-audit.ts +++ b/packages/server/src/setup/server-audit.ts @@ -89,7 +89,7 @@ export const serverAudit = async (serverId: string) => { .on("data", (data: string) => { output += data; }) - .stderr.on("data", (data) => {}); + .stderr.on("data", (_data) => {}); }); }) .on("error", (err) => { diff --git a/packages/server/src/setup/server-validate.ts b/packages/server/src/setup/server-validate.ts index 4ca21df85..c86206b61 100644 --- a/packages/server/src/setup/server-validate.ts +++ b/packages/server/src/setup/server-validate.ts @@ -128,7 +128,7 @@ export const serverValidate = async (serverId: string) => { .on("data", (data: string) => { output += data; }) - .stderr.on("data", (data) => {}); + .stderr.on("data", (_data) => {}); }); }) .on("error", (err) => { diff --git a/packages/server/src/setup/setup.ts b/packages/server/src/setup/setup.ts index c59877022..eeef32dd2 100644 --- a/packages/server/src/setup/setup.ts +++ b/packages/server/src/setup/setup.ts @@ -18,7 +18,7 @@ export const dockerSwarmInitialized = async () => { await docker.swarmInspect(); return true; - } catch (e) { + } catch (_e) { return false; } }; @@ -41,7 +41,7 @@ export const dockerNetworkInitialized = async () => { try { await docker.getNetwork("dokploy-network").inspect(); return true; - } catch (e) { + } catch (_e) { return false; } }; diff --git a/packages/server/src/setup/traefik-setup.ts b/packages/server/src/setup/traefik-setup.ts index 1d60e577c..4fb570f2d 100644 --- a/packages/server/src/setup/traefik-setup.ts +++ b/packages/server/src/setup/traefik-setup.ts @@ -127,7 +127,7 @@ export const initializeTraefik = async ({ }); console.log("Traefik Started ✅"); - } catch (error) { + } catch (_error) { await docker.createService(settings); console.log("Traefik Not Found: Starting ✅"); } diff --git a/packages/server/src/types/with.ts b/packages/server/src/types/with.ts index c4826f734..467020a21 100644 --- a/packages/server/src/types/with.ts +++ b/packages/server/src/types/with.ts @@ -36,7 +36,7 @@ type AnyObj = Record; type ZodObj = { [key in keyof T]: z.ZodType; }; -const zObject = (arg: ZodObj) => z.object(arg); +const _zObject = (arg: ZodObj) => z.object(arg); // const goodDogScheme = zObject({ // // prueba: schema.selectDatabaseSchema, diff --git a/packages/server/src/utils/access-log/handler.ts b/packages/server/src/utils/access-log/handler.ts index 5cff7f837..bbd32cff2 100644 --- a/packages/server/src/utils/access-log/handler.ts +++ b/packages/server/src/utils/access-log/handler.ts @@ -32,7 +32,7 @@ class LogRotationManager { // return setting?.enableLogRotation ?? false; } - private async setStateInDB(active: boolean): Promise { + private async setStateInDB(_active: boolean): Promise { // const admin = await db.query.admins.findFirst({}); // if (!admin) { // return; diff --git a/packages/server/src/utils/backups/utils.ts b/packages/server/src/utils/backups/utils.ts index 0d78ff961..c76f79626 100644 --- a/packages/server/src/utils/backups/utils.ts +++ b/packages/server/src/utils/backups/utils.ts @@ -28,7 +28,7 @@ export const removeScheduleBackup = (backupId: string) => { }; export const getS3Credentials = (destination: Destination) => { - const { accessKey, secretAccessKey, bucket, region, endpoint, provider } = + const { accessKey, secretAccessKey, region, endpoint, provider } = destination; const rcloneFlags = [ `--s3-access-key-id=${accessKey}`, diff --git a/packages/server/src/utils/builders/compose.ts b/packages/server/src/utils/builders/compose.ts index cbf951c73..19e7d1529 100644 --- a/packages/server/src/utils/builders/compose.ts +++ b/packages/server/src/utils/builders/compose.ts @@ -98,8 +98,7 @@ export const getBuildComposeCommand = async ( logPath: string, ) => { const { COMPOSE_PATH } = paths(true); - const { sourceType, appName, mounts, composeType, domains, composePath } = - compose; + const { sourceType, appName, mounts, composeType, domains } = compose; const command = createCommand(compose); const envCommand = getCreateEnvFileCommand(compose); const projectPath = join(COMPOSE_PATH, compose.appName, "code"); diff --git a/packages/server/src/utils/builders/index.ts b/packages/server/src/utils/builders/index.ts index d67482755..d777b1a36 100644 --- a/packages/server/src/utils/builders/index.ts +++ b/packages/server/src/utils/builders/index.ts @@ -197,7 +197,7 @@ export const mechanizeDockerContainer = async ( ForceUpdate: inspect.Spec.TaskTemplate.ForceUpdate + 1, }, }); - } catch (error) { + } catch (_error) { await docker.createService(settings); } }; diff --git a/packages/server/src/utils/builders/nixpacks.ts b/packages/server/src/utils/builders/nixpacks.ts index 56560e4e2..c13f82a56 100644 --- a/packages/server/src/utils/builders/nixpacks.ts +++ b/packages/server/src/utils/builders/nixpacks.ts @@ -91,7 +91,7 @@ export const getNixpacksCommand = ( application: ApplicationNested, logPath: string, ) => { - const { env, appName, publishDirectory, serverId } = application; + const { env, appName, publishDirectory } = application; const buildAppDirectory = getBuildAppDirectory(application); const buildContainerId = `${appName}-${nanoid(10)}`; diff --git a/packages/server/src/utils/databases/mariadb.ts b/packages/server/src/utils/databases/mariadb.ts index d1b41fc33..ead5a618a 100644 --- a/packages/server/src/utils/databases/mariadb.ts +++ b/packages/server/src/utils/databases/mariadb.ts @@ -98,7 +98,7 @@ export const buildMariadb = async (mariadb: MariadbNested) => { version: Number.parseInt(inspect.Version.Index), ...settings, }); - } catch (error) { + } catch (_error) { await docker.createService(settings); } }; diff --git a/packages/server/src/utils/databases/mongo.ts b/packages/server/src/utils/databases/mongo.ts index 5af58eef7..ace9c9721 100644 --- a/packages/server/src/utils/databases/mongo.ts +++ b/packages/server/src/utils/databases/mongo.ts @@ -152,7 +152,7 @@ ${command ?? "wait $MONGOD_PID"}`; version: Number.parseInt(inspect.Version.Index), ...settings, }); - } catch (error) { + } catch (_error) { await docker.createService(settings); } }; diff --git a/packages/server/src/utils/databases/mysql.ts b/packages/server/src/utils/databases/mysql.ts index 5a6911771..de28cfe6b 100644 --- a/packages/server/src/utils/databases/mysql.ts +++ b/packages/server/src/utils/databases/mysql.ts @@ -104,7 +104,7 @@ export const buildMysql = async (mysql: MysqlNested) => { version: Number.parseInt(inspect.Version.Index), ...settings, }); - } catch (error) { + } catch (_error) { await docker.createService(settings); } }; diff --git a/packages/server/src/utils/databases/redis.ts b/packages/server/src/utils/databases/redis.ts index 724069a17..aef862802 100644 --- a/packages/server/src/utils/databases/redis.ts +++ b/packages/server/src/utils/databases/redis.ts @@ -95,7 +95,7 @@ export const buildRedis = async (redis: RedisNested) => { version: Number.parseInt(inspect.Version.Index), ...settings, }); - } catch (error) { + } catch (_error) { await docker.createService(settings); } }; diff --git a/packages/server/src/utils/docker/domain.ts b/packages/server/src/utils/docker/domain.ts index 8a1b0608f..c4ced3f44 100644 --- a/packages/server/src/utils/docker/domain.ts +++ b/packages/server/src/utils/docker/domain.ts @@ -109,7 +109,7 @@ export const loadDockerComposeRemote = async ( if (!stdout) return null; const parsedConfig = load(stdout) as ComposeSpecification; return parsedConfig; - } catch (err) { + } catch (_err) { return null; } }; diff --git a/packages/server/src/utils/docker/utils.ts b/packages/server/src/utils/docker/utils.ts index 062e07226..71b7e4aac 100644 --- a/packages/server/src/utils/docker/utils.ts +++ b/packages/server/src/utils/docker/utils.ts @@ -100,7 +100,7 @@ export const containerExists = async (containerName: string) => { try { await container.inspect(); return true; - } catch (error) { + } catch (_error) { return false; } }; @@ -240,7 +240,7 @@ export const startServiceRemote = async (serverId: string, appName: string) => { export const removeService = async ( appName: string, serverId?: string | null, - deleteVolumes = false, + _deleteVolumes = false, ) => { try { const command = `docker service rm ${appName}`; diff --git a/packages/server/src/utils/gpu-setup.ts b/packages/server/src/utils/gpu-setup.ts index 6a6611b4a..a815a00cc 100644 --- a/packages/server/src/utils/gpu-setup.ts +++ b/packages/server/src/utils/gpu-setup.ts @@ -34,7 +34,7 @@ export async function checkGPUStatus(serverId?: string): Promise { ...gpuInfo, ...cudaInfo, }; - } catch (error) { + } catch (_error) { return { driverInstalled: false, driverVersion: undefined, @@ -315,7 +315,7 @@ const setupLocalServer = async (daemonConfig: any) => { try { await execAsync(setupCommands); - } catch (error) { + } catch (_error) { throw new Error( "Failed to configure GPU support. Please ensure you have sudo privileges and try again.", ); diff --git a/packages/server/src/utils/process/execAsync.ts b/packages/server/src/utils/process/execAsync.ts index 19a16ac1e..aee1e821a 100644 --- a/packages/server/src/utils/process/execAsync.ts +++ b/packages/server/src/utils/process/execAsync.ts @@ -27,7 +27,7 @@ export const execAsyncRemote = async ( throw err; } stream - .on("close", (code: number, signal: string) => { + .on("close", (code: number, _signal: string) => { conn.end(); if (code === 0) { resolve({ stdout, stderr }); diff --git a/packages/server/src/utils/providers/bitbucket.ts b/packages/server/src/utils/providers/bitbucket.ts index 7059e65f7..dd98a93bd 100644 --- a/packages/server/src/utils/providers/bitbucket.ts +++ b/packages/server/src/utils/providers/bitbucket.ts @@ -176,7 +176,6 @@ export const getBitbucketCloneCommand = async ( bitbucketBranch, bitbucketId, serverId, - bitbucket, } = entity; if (!serverId) { diff --git a/packages/server/src/utils/providers/git.ts b/packages/server/src/utils/providers/git.ts index 8f8a38301..c26af3af2 100644 --- a/packages/server/src/utils/providers/git.ts +++ b/packages/server/src/utils/providers/git.ts @@ -320,7 +320,7 @@ export const cloneGitRawRepository = async (entity: { outputPath, "--progress", ], - (data) => {}, + (_data) => {}, { env: { ...process.env, diff --git a/packages/server/src/utils/providers/gitlab.ts b/packages/server/src/utils/providers/gitlab.ts index a2c4b8ccb..c380a9203 100644 --- a/packages/server/src/utils/providers/gitlab.ts +++ b/packages/server/src/utils/providers/gitlab.ts @@ -162,8 +162,6 @@ export const getGitlabCloneCommand = async ( ) => { const { appName, - gitlabRepository, - gitlabOwner, gitlabPathNamespace, gitlabBranch, gitlabId, @@ -328,14 +326,7 @@ export const getGitlabBranches = async (input: { }; export const cloneRawGitlabRepository = async (entity: Compose) => { - const { - appName, - gitlabRepository, - gitlabOwner, - gitlabBranch, - gitlabId, - gitlabPathNamespace, - } = entity; + const { appName, gitlabBranch, gitlabId, gitlabPathNamespace } = entity; if (!gitlabId) { throw new TRPCError({ diff --git a/packages/server/src/utils/traefik/application.ts b/packages/server/src/utils/traefik/application.ts index 4434d8585..61150abf6 100644 --- a/packages/server/src/utils/traefik/application.ts +++ b/packages/server/src/utils/traefik/application.ts @@ -67,7 +67,7 @@ export const removeTraefikConfig = async ( if (fs.existsSync(configPath)) { await fs.promises.unlink(configPath); } - } catch (error) {} + } catch (_error) {} }; export const removeTraefikConfigRemote = async ( @@ -78,7 +78,7 @@ export const removeTraefikConfigRemote = async ( const { DYNAMIC_TRAEFIK_PATH } = paths(true); const configPath = path.join(DYNAMIC_TRAEFIK_PATH, `${appName}.yml`); await execAsyncRemote(serverId, `rm ${configPath}`); - } catch (error) {} + } catch (_error) {} }; export const loadOrCreateConfig = (appName: string): FileConfig => { @@ -110,7 +110,7 @@ export const loadOrCreateConfigRemote = async ( http: { routers: {}, services: {} }, }; return parsedConfig; - } catch (err) { + } catch (_err) { return fileConfig; } }; @@ -132,7 +132,7 @@ export const readRemoteConfig = async (serverId: string, appName: string) => { const { stdout } = await execAsyncRemote(serverId, `cat ${configPath}`); if (!stdout) return null; return stdout; - } catch (err) { + } catch (_err) { return null; } }; diff --git a/packages/server/src/verification/send-verification-email.tsx b/packages/server/src/verification/send-verification-email.tsx new file mode 100644 index 000000000..0b3b3bdcc --- /dev/null +++ b/packages/server/src/verification/send-verification-email.tsx @@ -0,0 +1,49 @@ +import { + sendDiscordNotification, + sendEmailNotification, +} from "../utils/notifications/utils"; +export const sendVerificationEmail = async (email: string, url: string) => { + await sendEmailNotification( + { + fromAddress: process.env.SMTP_FROM_ADDRESS || "", + toAddresses: [email], + smtpServer: process.env.SMTP_SERVER || "", + smtpPort: Number(process.env.SMTP_PORT), + username: process.env.SMTP_USERNAME || "", + password: process.env.SMTP_PASSWORD || "", + }, + "Confirm your email | Dokploy", + ` + Welcome to Dokploy! + Please confirm your email by clicking the link below: + + Confirm Email + + `, + ); + + return true; +}; + +export const sendDiscordNotificationWelcome = async (email: string) => { + await sendDiscordNotification( + { + webhookUrl: process.env.DISCORD_WEBHOOK_URL || "", + }, + { + title: "New User Registered", + color: 0x00ff00, + fields: [ + { + name: "Email", + value: email, + inline: true, + }, + ], + timestamp: new Date(), + footer: { + text: "Dokploy User Registration Notification", + }, + }, + ); +};