mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-24 11:59:39 -05:00
logger, imageProcessing
This commit is contained in:
@@ -455,10 +455,10 @@ class NetworkService implements INetworkService {
|
||||
|
||||
// Priority-based matching to avoid ambiguity:
|
||||
// 1. Exact full ID match (64-char)
|
||||
let exactIdMatch = containers.find((c: any) => c.Id.toLowerCase() === normalizedInput);
|
||||
const exactIdMatch = containers.find((c: any) => c.Id.toLowerCase() === normalizedInput);
|
||||
|
||||
// 2. Exact container name match (case-insensitive)
|
||||
let exactNameMatch = containers.find((c: any) =>
|
||||
const exactNameMatch = containers.find((c: any) =>
|
||||
c.Names.some((name: string) => {
|
||||
const cleanName = name.replace(/^\/+/, "").toLowerCase();
|
||||
return cleanName === normalizedInput;
|
||||
@@ -466,10 +466,10 @@ class NetworkService implements INetworkService {
|
||||
);
|
||||
|
||||
// 3. Partial ID match (fallback for backwards compatibility)
|
||||
let partialIdMatch = containers.find((c: any) => c.Id.toLowerCase().startsWith(normalizedInput));
|
||||
const partialIdMatch = containers.find((c: any) => c.Id.toLowerCase().startsWith(normalizedInput));
|
||||
|
||||
// Select container based on priority
|
||||
let targetContainer = exactIdMatch || exactNameMatch || partialIdMatch;
|
||||
const targetContainer = exactIdMatch || exactNameMatch || partialIdMatch;
|
||||
|
||||
// Return negative response if no container
|
||||
if (!targetContainer) {
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
import sharp from "sharp";
|
||||
|
||||
const GenerateAvatarImage = async (file: Express.Multer.File) => {
|
||||
try {
|
||||
// Resize to target 64 * 64
|
||||
let resizedImageBuffer = await sharp(file.buffer)
|
||||
.resize({
|
||||
width: 64,
|
||||
height: 64,
|
||||
fit: "cover",
|
||||
})
|
||||
.toBuffer();
|
||||
// Resize to target 64 * 64
|
||||
let resizedImageBuffer = await sharp(file.buffer)
|
||||
.resize({
|
||||
width: 64,
|
||||
height: 64,
|
||||
fit: "cover",
|
||||
})
|
||||
.toBuffer();
|
||||
|
||||
//Get b64 string
|
||||
const base64Image = resizedImageBuffer.toString("base64");
|
||||
return base64Image;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
//Get b64 string
|
||||
const base64Image = resizedImageBuffer.toString("base64");
|
||||
return base64Image;
|
||||
};
|
||||
|
||||
export { GenerateAvatarImage };
|
||||
|
||||
@@ -44,7 +44,7 @@ class Logger implements ILogger {
|
||||
this.maxCacheSize = 1000;
|
||||
const consoleFormat = format.printf((info: Logform.TransformableInfo) => {
|
||||
const { level, service, method, details, timestamp, stack } = info;
|
||||
let message = info.message as string;
|
||||
const message = info.message as string;
|
||||
let formattedMessage: string = message;
|
||||
let formattedDetails: string | undefined;
|
||||
|
||||
@@ -57,10 +57,10 @@ class Logger implements ILogger {
|
||||
}
|
||||
|
||||
let msg = `${timestamp} ${level}:`;
|
||||
service && (msg += ` [${service}]`);
|
||||
method && (msg += `(${method})`);
|
||||
formattedMessage && (msg += ` ${formattedMessage}`);
|
||||
formattedDetails && (msg += ` (details: ${formattedDetails})`);
|
||||
if (service) msg += ` [${service}]`;
|
||||
if (method) msg += `(${method})`;
|
||||
if (formattedMessage) msg += ` ${formattedMessage}`;
|
||||
if (formattedDetails) msg += ` (details: ${formattedDetails})`;
|
||||
|
||||
if (typeof stack === "string") {
|
||||
const stackTrace = stack
|
||||
|
||||
Reference in New Issue
Block a user