Compare commits

..

No commits in common. "b48fe51f46bb2bd79058563e2fe7e65e1c476a0f" and "209ab9dd4813cdde284d069988206b08c85bb67c" have entirely different histories.

3 changed files with 3 additions and 15 deletions

View File

@ -11,7 +11,7 @@ if (!fs.existsSync(logFileDirectory)) {
const deleteLogFile =(filePath: string) => { const deleteLogFile =(filePath: string) => {
try { try {
fs.unlinkSync(filePath); fs.unlinkSync(filePath);
logger.info("Deleted expired log file", { filename: path.basename(__filename) }); logger.info("Deleted expired log file", { filename: __filename });
} catch (error) { } catch (error) {
logger.error("Failed to expired log file:", error); logger.error("Failed to expired log file:", error);
} }
@ -52,7 +52,7 @@ const consoleFormat = combine(
message = chalk.white(message); message = chalk.white(message);
filename = chalk.white(filename || "unknown") filename = chalk.white(filename || "unknown")
return `[${level}] ${timestamp} (${filename}): ${message}`; return `[${level}] (${filename}) ${timestamp}: ${message}`;
}) })
); );

View File

@ -1,15 +1,10 @@
import { Request, Response, NextFunction } from "express"; import { Request, Response, NextFunction } from "express";
import { client as bot } from "@bot/bot"; import { client as bot } from "@bot/bot";
import { getLogger } from "@server/../log";
const logger = getLogger(__filename);
// Todo: update this comment as a jsdoc
// The purpose of this middleware is to attach an object containing cached // The purpose of this middleware is to attach an object containing cached
// Discord servers to the response, which is accessible in the DOM. // Discord servers to the response, which is accessible in the DOM.
// This is primarily used for rendering servers on the sidebar. // This is primarily used for rendering servers on the sidebar.
export const attachGuilds = (_request: Request, response: Response, next: NextFunction) => { export const attachGuilds = (_request: Request, response: Response, next: NextFunction) => {
logger.debug(`Attaching ${bot.guilds.cache.size} cached guilds to the response locals`);
response.locals.guilds = bot.guilds.cache.map(guild => guild); response.locals.guilds = bot.guilds.cache.map(guild => guild);
next(); next();
} }

View File

@ -1,17 +1,10 @@
import { Request, Response, NextFunction } from "express"; import { Request, Response, NextFunction } from "express";
import { getLogger } from "@server/../log";
const logger = getLogger(__filename);
// This middleware returns the last segment of the url path. // This middleware returns the last segment of the url path.
// It's used to identify which tab to highlight as active on // It's used to identify which tab to highlight as active on
// the guild view at '/guild/<id>/<page>' // the guild view at '/guild/<id>/<page>'
export const guildTabHelper = (request: Request, response: Response, next: NextFunction) => { export const guildTabHelper = (request: Request, response: Response, next: NextFunction) => {
const currentPath = request.path.split("/") const currentPath = request.path.split("/")
const guildPage = currentPath[currentPath.length - 1]; response.locals.guildPage = currentPath[currentPath.length - 1]
logger.debug(`Attaching '${guildPage}' tab helper to response locals`);
response.locals.guildPage = guildPage;
next(); next();
} }