Compare commits
2 Commits
209ab9dd48
...
b48fe51f46
Author | SHA1 | Date | |
---|---|---|---|
b48fe51f46 | |||
27ecf0f9b2 |
@ -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: __filename });
|
logger.info("Deleted expired log file", { filename: path.basename(__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}] (${filename}) ${timestamp}: ${message}`;
|
return `[${level}] ${timestamp} (${filename}): ${message}`;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
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();
|
||||||
}
|
}
|
@ -1,10 +1,17 @@
|
|||||||
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("/")
|
||||||
response.locals.guildPage = currentPath[currentPath.length - 1]
|
const guildPage = currentPath[currentPath.length - 1];
|
||||||
|
|
||||||
|
logger.debug(`Attaching '${guildPage}' tab helper to response locals`);
|
||||||
|
|
||||||
|
response.locals.guildPage = guildPage;
|
||||||
next();
|
next();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user