refactor(core): get rid of as any for image routes

This commit is contained in:
Elian Doran
2026-04-12 18:37:21 +03:00
parent f034454ec9
commit 3ad20e43f1
2 changed files with 9 additions and 4 deletions

View File

@@ -1,7 +1,9 @@
import { ConvertAttachmentToNoteResponse } from "@triliumnext/commons";
import { ValidationError } from "../../errors";
import type { Request } from "express";
import type { File } from "../../services/import/common.js";
type FileRequest<P> = Omit<Request<P>, "file"> & { file?: File };
import becca from "../../becca/becca.js";
import blobService from "../../services/blob.js";
@@ -44,9 +46,9 @@ function saveAttachment(req: Request<{ noteId: string }>) {
note.saveAttachment({ attachmentId, role, mime, title, content }, matchBy);
}
function uploadAttachment(req: Request<{ noteId: string }>) {
function uploadAttachment(req: FileRequest<{ noteId: string }>) {
const { noteId } = req.params;
const { file } = req as any; // TODO: Add support for file upload in type definitions and remove 'as any' cast
const { file } = req;
if (!file) {
return {

View File

@@ -1,4 +1,7 @@
import type { Request, Response } from "express";
import type { File } from "../../services/import/common.js";
type FileRequest<P> = Omit<Request<P>, "file"> & { file?: File };
import becca from "../../becca/becca.js";
import type BNote from "../../becca/entities/bnote.js";
@@ -103,9 +106,9 @@ function returnAttachedImage(req: Request<{ attachmentId: string }>, res: Respon
}
}
function updateImage(req: Request<{ noteId: string }>) {
function updateImage(req: FileRequest<{ noteId: string }>) {
const { noteId } = req.params;
const { file } = req as any; // TODO: Add support for file upload in type definitions and remove 'as any' cast
const { file } = req;
const _note = becca.getNoteOrThrow(noteId);