diff --git a/index.js b/index.js index 425c543..2fff1d2 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +import "./middleware/catchErrors.js"; import { uvPath } from "@titaniumnetwork-dev/ultraviolet"; import { epoxyPath } from "@mercuryworkshop/epoxy-transport"; import { libcurlPath } from "@mercuryworkshop/libcurl-transport"; @@ -13,7 +14,6 @@ import wisp from "wisp-server-node"; import router from "./middleware/ProxyExt/index.js"; import { handler as astroSSR } from "./dist/server/entry.mjs"; import cookies from "cookie-parser"; -import "./middleware/catchErrors.js"; dotenv.config(); @@ -21,7 +21,8 @@ const whiteListedDomains = ["aluu.xyz", "localhost"]; const LICENSE_SERVER_URL = "https://license.mercurywork.shop/validate?license="; const MASQR_ENABLED = process.env.MASQR_ENABLED; -const log = (message) => console.log(chalk.gray("[Alu] " + message)); +const log = (message) => console.log(chalk.gray.bold("[Alu] " + message)); +const success = (message) => console.log(chalk.green.bold("[Alu] " + message)); const PORT = process.env.PORT; log("Starting Rammerhead..."); @@ -137,11 +138,11 @@ server.on("upgrade", (req, socket, head) => { }); log("Starting Alu..."); -console.log(chalk.green("[Alu] Alu started successfully!")); +success("Alu started successfully!"); server.on("listening", () => { - console.log(chalk.green(`[Alu] Server running at http://localhost:${PORT}/.`)); + success(`Server running at http://localhost:${PORT}/.`); }); server.listen({ port: PORT, -}); +}); \ No newline at end of file diff --git a/middleware/catchErrors.js b/middleware/catchErrors.js index cbbb413..a4e649e 100644 --- a/middleware/catchErrors.js +++ b/middleware/catchErrors.js @@ -1,6 +1,11 @@ import chalk from "chalk"; -process.on("uncaughtException", (err) => { - console.log(chalk.red("[Alu] Uncaught exception!", err)); +process.on('uncaughtException', (err) => { + console.log(chalk.bold.red(`[Alu] Caught error!\n${err.stack}`)); + process.exit(1); +}); + +process.on("uncaughtExceptionMonitor", (err) => { + console.log(chalk.bold.red(`[Alu] Caught error!\n${err.stack}`)); process.exit(1); -}); \ No newline at end of file +}) \ No newline at end of file