Repository: louislam/uptime-kuma
File: server/setup-database.js (JavaScript)

Code before:
                    supportedDBTypes.push("embedded-mariadb");
                }

                // Validate input
                if (typeof dbConfig !== "object") {
                    response.status(400).json("Invalid dbConfig");
                    this.runningSetup = false;
                    return;
                }

                if (!dbConfig.type) {
                    response.status(400).json("Database Type is required");
                    this.runningSetup = false;
                    return;
                }

                if (!supportedDBTypes.includes(dbConfig.type)) {
                    response.status(400).json("Unsupported Database Type");
                    this.runningSetup = false;
                    return;
                }

                // External MariaDB
                if (dbConfig.type === "mariadb") {
                    // If socketPath is provided and not empty, validate it
                    if (process.env.UPTIME_KUMA_DB_SOCKET && process.env.UPTIME_KUMA_DB_SOCKET.trim().length > 0) {
                        dbConfig.socketPath = process.env.UPTIME_KUMA_DB_SOCKET;
                    } else {
                        // socketPath not provided, hostname and port are required
                        if (!dbConfig.hostname) {
                            response.status(400).json("Hostname is required");
                            this.runningSetup = false;
                            return;
                        }

                        if (!dbConfig.port) {
                            response.status(400).json("Port is required");
                            this.runningSetup = false;
                            return;
                        }
                    }

                    if (!dbConfig.dbName) {
                        response.status(400).json("Database name is required");
                        this.runningSetup = false;
                        return;
                    }

                    if (!dbConfig.username) {
                        response.status(400).json("Username is required");
                        this.runningSetup = false;

Review comment (suggestion):
```suggestion
                    if (process.env.UPTIME_KUMA_DB_SOCKET?.trim().length > 0) {
```

Code after:

                // Validate input
                if (typeof dbConfig !== "object") {
                    response.status(400).json("Invalid dbConfig");
                    this.runningSetup = false;
                    return;
                }

                if (!dbConfig.type) {
                    response.status(400).json("Database Type is required");
                    this.runningSetup = false;
                    return;
                }

                if (!supportedDBTypes.includes(dbConfig.type)) {
                    response.status(400).json("Unsupported Database Type");
                    this.runningSetup = false;
                    return;
                }

                // External MariaDB
                if (dbConfig.type === "mariadb") {
                    // If socketPath is provided and not empty, validate it
                    if (process.env.UPTIME_KUMA_DB_SOCKET?.trim().length > 0) {
                        dbConfig.socketPath = process.env.UPTIME_KUMA_DB_SOCKET.trim();
                    } else {
                        // socketPath not provided, hostname and port are required
                        if (!dbConfig.hostname) {
                            response.status(400).json("Hostname is required");
                            this.runningSetup = false;
                            return;
                        }

                        if (!dbConfig.port) {
                            response.status(400).json("Port is required");
                            this.runningSetup = false;
                            return;
                        }
                    }

                    if (!dbConfig.dbName) {
                        response.status(400).json("Database name is required");
                        this.runningSetup = false;
                        return;
                    }

                    if (!dbConfig.username) {
                        response.status(400).json("Username is required");
                        this.runningSetup = false;
                        return;
                    }