Skip to content

Commit

Permalink
Better error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
wearrrrr committed Oct 4, 2024
1 parent 7526623 commit 9a48ae3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -13,15 +14,15 @@ 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();

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...");
Expand Down Expand Up @@ -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,
});
});
11 changes: 8 additions & 3 deletions middleware/catchErrors.js
Original file line number Diff line number Diff line change
@@ -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);
});
})

0 comments on commit 9a48ae3

Please sign in to comment.