mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-21 19:38:47 +00:00
refactor(server): move token generation function to a separate utility for better organization
This commit is contained in:
@@ -22,6 +22,14 @@ import { Client } from "ssh2";
|
|||||||
import { recreateDirectory } from "../utils/filesystem/directory";
|
import { recreateDirectory } from "../utils/filesystem/directory";
|
||||||
import { setupMonitoring } from "./monitoring-setup";
|
import { setupMonitoring } from "./monitoring-setup";
|
||||||
|
|
||||||
|
const generateToken = () => {
|
||||||
|
const array = new Uint8Array(64);
|
||||||
|
crypto.getRandomValues(array);
|
||||||
|
return Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join(
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const slugify = (text: string | undefined) => {
|
export const slugify = (text: string | undefined) => {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return "";
|
return "";
|
||||||
@@ -67,15 +75,6 @@ export const serverSetup = async (
|
|||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
onData?.("\nConfiguring Monitoring: 🔄\n");
|
onData?.("\nConfiguring Monitoring: 🔄\n");
|
||||||
|
|
||||||
// Generate token and configure monitoring
|
|
||||||
const generateToken = () => {
|
|
||||||
const array = new Uint8Array(64);
|
|
||||||
crypto.getRandomValues(array);
|
|
||||||
return Array.from(array, (byte) =>
|
|
||||||
byte.toString(16).padStart(2, "0"),
|
|
||||||
).join("");
|
|
||||||
};
|
|
||||||
|
|
||||||
const baseUrl = await getDokployUrl();
|
const baseUrl = await getDokployUrl();
|
||||||
const token = generateToken();
|
const token = generateToken();
|
||||||
const urlCallback = `${baseUrl}/api/trpc/notification.receiveNotification`;
|
const urlCallback = `${baseUrl}/api/trpc/notification.receiveNotification`;
|
||||||
|
|||||||
Reference in New Issue
Block a user