mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 01:26:52 +02:00
refactor(core): get rid of as any for image routes
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user