feat: 所有的类型检查
This commit is contained in:
1 parent
19888d52dc
commit
df824d77ae
50 files changed
+477
-94
No files matched your search
@@ -3,22 +3,22 @@
|
||||
*/
|
||||
|
||||
import express from 'express';
|
||||
import type { WebUiConfigType } from './types';
|
||||
import type { WebUiConfigType } from './src/types';
|
||||
import { createServer } from 'http';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { createServer as createHttpsServer } from 'https';
|
||||
import { LogWrapper } from 'napcat-common/src/log';
|
||||
import { NapCatPathWrapper } from 'napcat-common/src/path';
|
||||
import { WebUiConfigWrapper } from '@/napcat-webui-backend/helper/config';
|
||||
import { ALLRouter } from '@/napcat-webui-backend/router';
|
||||
import { cors } from '@/napcat-webui-backend/middleware/cors';
|
||||
import { createUrl, getRandomToken } from '@/napcat-webui-backend/utils/url';
|
||||
import { sendError } from '@/napcat-webui-backend/utils/response';
|
||||
import { WebUiConfigWrapper } from '@/napcat-webui-backend/src/helper/config';
|
||||
import { ALLRouter } from '@/napcat-webui-backend/src/router';
|
||||
import { cors } from '@/napcat-webui-backend/src/middleware/cors';
|
||||
import { createUrl, getRandomToken } from '@/napcat-webui-backend/src/utils/url';
|
||||
import { sendError } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { join } from 'node:path';
|
||||
import { terminalManager } from '@/napcat-webui-backend/terminal/terminal_manager';
|
||||
import { terminalManager } from '@/napcat-webui-backend/src/terminal/terminal_manager';
|
||||
import multer from 'multer';
|
||||
import * as net from 'node:net';
|
||||
import { WebUiDataRuntime } from './helper/Data';
|
||||
import { WebUiDataRuntime } from './src/helper/Data';
|
||||
import { existsSync, readFileSync } from 'node:fs'; // 引入multer用于错误捕获
|
||||
|
||||
// 实例化Express
|
||||
@@ -3,7 +3,10 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.ts"
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { RequestHandler } from 'express';
|
||||
|
||||
import { AuthHelper } from '@/napcat-webui-backend/src/helper/SignToken';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data';
|
||||
import { sendSuccess, sendError } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { isEmpty } from '@/napcat-webui-backend/src/utils/check';
|
||||
import { WebUiConfig, getInitialWebUiToken, setInitialWebUiToken } from '@/napcat-webui-backend/index';
|
||||
|
||||
import { AuthHelper } from '@/napcat-webui-backend/helper/SignToken';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data';
|
||||
import { sendSuccess, sendError } from '@/napcat-webui-backend/utils/response';
|
||||
import { isEmpty } from '@/napcat-webui-backend/utils/check';
|
||||
|
||||
// 登录
|
||||
export const LoginHandler: RequestHandler = async (req, res) => {
|
||||
// 获取WebUI配置
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { RequestHandler } from 'express';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data';
|
||||
|
||||
import { sendSuccess } from '@/napcat-webui-backend/utils/response';
|
||||
import { sendSuccess } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { WebUiConfig } from '@/napcat-webui-backend/index';
|
||||
|
||||
export const GetNapCatVersion: RequestHandler = (_, res) => {
|
||||
|
||||
@@ -3,9 +3,9 @@ import { existsSync, readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { loadConfig, OneBotConfig } from 'napcat-onebot/config/config';
|
||||
import { webUiPathWrapper } from '@/napcat-webui-backend/index';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data';
|
||||
import { sendError, sendSuccess } from '@/napcat-webui-backend/utils/response';
|
||||
import { isEmpty } from '@/napcat-webui-backend/utils/check';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data';
|
||||
import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { isEmpty } from '@/napcat-webui-backend/src/utils/check';
|
||||
import json5 from 'json5';
|
||||
|
||||
// 获取OneBot11配置
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { RequestHandler } from 'express';
|
||||
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data';
|
||||
import { isEmpty } from '@/napcat-webui-backend/utils/check';
|
||||
import { sendError, sendSuccess } from '@/napcat-webui-backend/utils/response';
|
||||
import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data';
|
||||
import { isEmpty } from '@/napcat-webui-backend/src/utils/check';
|
||||
import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { WebUiConfig } from '@/napcat-webui-backend/index';
|
||||
|
||||
// 获取QQ登录二维码
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { RequestHandler } from 'express';
|
||||
import { WebUiConfig } from '@/napcat-webui-backend/index';
|
||||
import { sendError, sendSuccess } from '@/napcat-webui-backend/utils/response';
|
||||
import { isEmpty } from '@/napcat-webui-backend/utils/check';
|
||||
import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response';
|
||||
import { isEmpty } from '@/napcat-webui-backend/src/utils/check';
|
||||
|
||||
// 获取WebUI基础配置
|
||||
export const GetWebUIConfigHandler: RequestHandler = async (_, res) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import crypto from 'crypto';
|
||||
import store from 'napcat-common/src/store';
|
||||
import type { WebUiCredentialJson, WebUiCredentialInnerJson } from '@/napcat-webui-backend/types';
|
||||
import type { WebUiCredentialJson, WebUiCredentialInnerJson } from '@/napcat-webui-backend/src/types';
|
||||
export class AuthHelper {
|
||||
private static readonly secretKey = Math.random().toString(36).slice(2);
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import { NextFunction, Request, Response } from 'express';
|
||||
|
||||
import { getInitialWebUiToken } from '@/napcat-webui-backend/index';
|
||||
|
||||
import { AuthHelper } from '@/napcat-webui-backend/helper/SignToken';
|
||||
import { sendError } from '@/napcat-webui-backend/utils/response';
|
||||
import type { WebUiCredentialJson } from '@/napcat-webui-backend/types';
|
||||
import { AuthHelper } from '@/napcat-webui-backend/src/helper/SignToken';
|
||||
import { sendError } from '@/napcat-webui-backend/src/utils/response';
|
||||
import type { WebUiCredentialJson } from '@/napcat-webui-backend/src/types';
|
||||
|
||||
// 鉴权中间件
|
||||
export async function auth (req: Request, res: Response, next: NextFunction) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Router } from 'express';
|
||||
import { GetThemeConfigHandler, GetNapCatVersion, QQVersionHandler, SetThemeConfigHandler } from '../api/BaseInfo';
|
||||
import { StatusRealTimeHandler } from '@/napcat-webui-backend/api/Status';
|
||||
import { StatusRealTimeHandler } from '@/napcat-webui-backend/src/api/Status';
|
||||
import { GetProxyHandler } from '../api/Proxy';
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/api/OB11Config';
|
||||
import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/src/api/OB11Config';
|
||||
|
||||
const router = Router();
|
||||
// router:读取配置
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
getQQLoginInfoHandler,
|
||||
getAutoLoginAccountHandler,
|
||||
setAutoLoginAccountHandler,
|
||||
} from '@/napcat-webui-backend/api/QQLogin';
|
||||
} from '@/napcat-webui-backend/src/api/QQLogin';
|
||||
|
||||
const router = Router();
|
||||
// router:获取快速登录列表
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
GetDisableNonLANAccessHandler,
|
||||
UpdateDisableNonLANAccessHandler,
|
||||
UpdateWebUIConfigHandler,
|
||||
} from '@/napcat-webui-backend/api/WebUIConfig';
|
||||
} from '@/napcat-webui-backend/src/api/WebUIConfig';
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
LoginHandler,
|
||||
LogoutHandler,
|
||||
UpdateTokenHandler,
|
||||
} from '@/napcat-webui-backend/api/Auth';
|
||||
} from '@/napcat-webui-backend/src/api/Auth';
|
||||
|
||||
const router = Router();
|
||||
// router:登录
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
import { Router } from 'express';
|
||||
|
||||
import { OB11ConfigRouter } from '@/napcat-webui-backend/router/OB11Config';
|
||||
import { auth } from '@/napcat-webui-backend/middleware/auth';
|
||||
import { sendSuccess } from '@/napcat-webui-backend/utils/response';
|
||||
import { OB11ConfigRouter } from '@/napcat-webui-backend/src/router/OB11Config';
|
||||
import { auth } from '@/napcat-webui-backend/src/middleware/auth';
|
||||
import { sendSuccess } from '@/napcat-webui-backend/src/utils/response';
|
||||
|
||||
import { QQLoginRouter } from '@/napcat-webui-backend/router/QQLogin';
|
||||
import { AuthRouter } from '@/napcat-webui-backend/router/auth';
|
||||
import { LogRouter } from '@/napcat-webui-backend/router/Log';
|
||||
import { BaseRouter } from '@/napcat-webui-backend/router/Base';
|
||||
import { QQLoginRouter } from '@/napcat-webui-backend/src/router/QQLogin';
|
||||
import { AuthRouter } from '@/napcat-webui-backend/src/router/auth';
|
||||
import { LogRouter } from '@/napcat-webui-backend/src/router/Log';
|
||||
import { BaseRouter } from '@/napcat-webui-backend/src/router/Base';
|
||||
import { FileRouter } from './File';
|
||||
import { WebUIConfigRouter } from './WebUIConfig';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// import './init-dynamic-dirname';
|
||||
import { WebUiConfig } from '../index';
|
||||
import { WebUiConfig } from '../../index';
|
||||
import { AuthHelper } from '../helper/SignToken';
|
||||
import type { WebUiCredentialJson } from '@/napcat-webui-backend/types';
|
||||
import type { WebUiCredentialJson } from '@/napcat-webui-backend/src/types';
|
||||
import { LogWrapper } from 'napcat-common/src/log';
|
||||
import { WebSocket, WebSocketServer } from 'ws';
|
||||
import os from 'os';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Response } from 'express';
|
||||
|
||||
import { ResponseCode, HttpStatusCode } from '@/napcat-webui-backend/const/status';
|
||||
import { ResponseCode, HttpStatusCode } from '@/napcat-webui-backend/src/const/status';
|
||||
|
||||
export const sendResponse = <T>(
|
||||
res: Response,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"rootDir": ".",
|
||||
"noEmit": false,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
@@ -36,14 +36,15 @@
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/napcat-webui-backend/*": [
|
||||
"src/*"
|
||||
"@/*": [
|
||||
"../*"
|
||||
]
|
||||
},
|
||||
"skipLibCheck": true,
|
||||
"skipDefaultLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"*.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.d.ts"
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user