Refactor type annotations and router initialization

Standardized type annotations for interfaces in user.ts and improved type safety in webapi.ts. Updated all Express router initializations to explicitly declare the Router type. Added missing RequestHandler typings in uploader modules for better type checking.
This commit is contained in:
手瓜一十雪 committed 2026-01-22 17:35:54 +08:00
1 parent e25dd38acd
commit dd9b2252b7
16 files changed
+123 -121

No files matched your search

@@ -1,5 +1,5 @@
import multer from 'multer';
import { Request, Response } from 'express';
import { Request, Response, RequestHandler } from 'express';
import fs from 'fs';
import path from 'path';
import { randomUUID } from 'crypto';
@@ -65,7 +65,7 @@ export const createDiskStorage = (uploadPath: string) => {
});
};
export const createDiskUpload = (uploadPath: string) => {
export const createDiskUpload = (uploadPath: string): RequestHandler => {
const upload = multer({
storage: createDiskStorage(uploadPath),
limits: {
@@ -1,7 +1,7 @@
import multer from 'multer';
import path from 'path';
import fs from 'fs';
import type { Request, Response } from 'express';
import type { Request, Response, RequestHandler } from 'express';
import { WebUiConfig } from '@/napcat-webui-backend/index';
// 支持的字体格式
@@ -42,7 +42,7 @@ export const webUIFontStorage = multer.diskStorage({
},
});
export const webUIFontUpload = multer({
export const webUIFontUpload: RequestHandler = multer({
storage: webUIFontStorage,
fileFilter: (_, file, cb) => {
// 验证文件类型