chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -3,7 +3,7 @@
import imageService from "../../services/image.js";
import becca from "../../becca/becca.js";
import fs from "fs";
import { Request, Response } from 'express';
import { Request, Response } from "express";
import BNote from "../../becca/entities/bnote.js";
import BRevision from "../../becca/entities/brevision.js";
import { RESOURCE_DIR } from "../../services/resource_dir.js";
@@ -22,27 +22,27 @@ function returnImageFromRevision(req: Request, res: Response) {
function returnImageInt(image: BNote | BRevision | null, res: Response) {
if (!image) {
res.set('Content-Type', 'image/png');
res.set("Content-Type", "image/png");
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
} else if (![ "image", "canvas", "mermaid", "mindMap" ].includes(image.type)) {
} else if (!["image", "canvas", "mermaid", "mindMap"].includes(image.type)) {
return res.sendStatus(400);
}
if (image.type === 'canvas') {
renderSvgAttachment(image, res, 'canvas-export.svg');
} else if (image.type === 'mermaid') {
renderSvgAttachment(image, res, 'mermaid-export.svg');
if (image.type === "canvas") {
renderSvgAttachment(image, res, "canvas-export.svg");
} else if (image.type === "mermaid") {
renderSvgAttachment(image, res, "mermaid-export.svg");
} else if (image.type === "mindMap") {
renderSvgAttachment(image, res, 'mindmap-export.svg');
renderSvgAttachment(image, res, "mindmap-export.svg");
} else {
res.set('Content-Type', image.mime);
res.set("Content-Type", image.mime);
res.set("Cache-Control", "no-cache, no-store, must-revalidate");
res.send(image.getContent());
}
}
function renderSvgAttachment(image: BNote | BRevision, res: Response, attachmentName: string) {
let svg: string | Buffer = '<svg/>'
let svg: string | Buffer = "<svg/>";
const attachment = image.getAttachmentByTitle(attachmentName);
if (attachment) {
@@ -56,34 +56,31 @@ function renderSvgAttachment(image: BNote | BRevision, res: Response, attachment
}
}
res.set('Content-Type', "image/svg+xml");
res.set("Content-Type", "image/svg+xml");
res.set("Cache-Control", "no-cache, no-store, must-revalidate");
res.send(svg);
}
function returnAttachedImage(req: Request, res: Response) {
const attachment = becca.getAttachment(req.params.attachmentId);
if (!attachment) {
res.set('Content-Type', 'image/png');
res.set("Content-Type", "image/png");
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
}
if (!["image"].includes(attachment.role)) {
return res.setHeader("Content-Type", "text/plain")
.status(400)
.send(`Attachment '${attachment.attachmentId}' has role '${attachment.role}', but 'image' was expected.`);
return res.setHeader("Content-Type", "text/plain").status(400).send(`Attachment '${attachment.attachmentId}' has role '${attachment.role}', but 'image' was expected.`);
}
res.set('Content-Type', attachment.mime);
res.set("Content-Type", attachment.mime);
res.set("Cache-Control", "no-cache, no-store, must-revalidate");
res.send(attachment.getContent());
}
function updateImage(req: Request) {
const {noteId} = req.params;
const {file} = req;
const { noteId } = req.params;
const { file } = req;
const note = becca.getNoteOrThrow(noteId);