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:
1 parent
772f07c58b
commit
01958d47a4
16 files changed
+123
-121
No files matched your search
@@ -3,7 +3,7 @@ import { GetThemeConfigHandler, GetNapCatVersion, QQVersionHandler, SetThemeConf
|
||||
import { StatusRealTimeHandler } from '@/napcat-webui-backend/src/api/Status';
|
||||
import { GetProxyHandler } from '../api/Proxy';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
// router: 获取nc的package.json信息
|
||||
router.get('/QQVersion', QQVersionHandler);
|
||||
router.get('/GetNapCatVersion', GetNapCatVersion);
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
DeleteWebUIFontHandler, // 添加上传处理器
|
||||
} from '../api/File';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
const apiLimiter = rateLimit({
|
||||
windowMs: 1 * 60 * 1000, // 1分钟内
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
CloseTerminalHandler,
|
||||
} from '../api/Log';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// 日志相关路由
|
||||
router.get('/GetLog', LogHandler);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Router } from 'express';
|
||||
|
||||
import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/src/api/OB11Config';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
// router:读取配置
|
||||
router.post('/GetConfig', OB11GetConfigHandler);
|
||||
// router:写入配置
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import { GetPluginListHandler, ReloadPluginHandler, SetPluginStatusHandler, UninstallPluginHandler } from '@/napcat-webui-backend/src/api/Plugin';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
router.get('/List', GetPluginListHandler);
|
||||
router.post('/Reload', ReloadPluginHandler);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import { RestartProcessHandler } from '../api/Process';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// POST /api/Process/Restart - 重启进程
|
||||
router.post('/Restart', RestartProcessHandler);
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
QQRefreshQRcodeHandler,
|
||||
} from '@/napcat-webui-backend/src/api/QQLogin';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
// router:获取快速登录列表
|
||||
router.all('/GetQuickLoginList', QQGetQuickLoginListHandler);
|
||||
// router:获取快速登录列表(新)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { Router } from 'express';
|
||||
import { UpdateNapCatHandler } from '@/napcat-webui-backend/src/api/UpdateNapCat';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// POST /api/UpdateNapCat/update - 更新NapCat
|
||||
router.post('/update', UpdateNapCatHandler);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
UpdateWebUIConfigHandler,
|
||||
} from '@/napcat-webui-backend/src/api/WebUIConfig';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// 获取WebUI基础配置
|
||||
router.get('/GetConfig', GetWebUIConfigHandler);
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
VerifyPasskeyAuthenticationHandler,
|
||||
} from '@/napcat-webui-backend/src/api/Auth';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
// router:登录
|
||||
router.post('/login', LoginHandler);
|
||||
// router:检查登录状态
|
||||
|
||||
@@ -19,7 +19,7 @@ import DebugRouter from '@/napcat-webui-backend/src/api/Debug';
|
||||
import { ProcessRouter } from './Process';
|
||||
import { PluginRouter } from './Plugin';
|
||||
|
||||
const router = Router();
|
||||
const router: Router = Router();
|
||||
|
||||
// 鉴权中间件
|
||||
router.use(auth);
|
||||
|
||||
Reference in new issue
Block a user