@ikenxuan/amagi 4.4.18 → 4.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/default/cjs/index.cjs +62 -11
- package/dist/default/esm/index.mjs +56 -12
- package/dist/default/index.d.ts +5 -3
- package/package.json +1 -1
|
@@ -7,6 +7,9 @@ var crypto = require('crypto');
|
|
|
7
7
|
var express = require('express');
|
|
8
8
|
var chalk = require('chalk');
|
|
9
9
|
var log4js = require('log4js');
|
|
10
|
+
var path = require('path');
|
|
11
|
+
var url = require('url');
|
|
12
|
+
var fs = require('fs');
|
|
10
13
|
|
|
11
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
15
|
|
|
@@ -14,6 +17,12 @@ var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
|
14
17
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
15
18
|
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
16
19
|
var log4js__default = /*#__PURE__*/_interopDefault(log4js);
|
|
20
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
21
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
22
|
+
|
|
23
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
24
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
25
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
17
26
|
|
|
18
27
|
// src/platform/bilibili/API.ts
|
|
19
28
|
var BiLiBiLiAPI = class {
|
|
@@ -2241,6 +2250,20 @@ async function getKuaishouData(methodType, arg2, arg3) {
|
|
|
2241
2250
|
var fetchDouyinData = getDouyinData;
|
|
2242
2251
|
var fetchBilibiliData = getBilibiliData;
|
|
2243
2252
|
var fetchKuaishouData = getKuaishouData;
|
|
2253
|
+
var getPackageLogsPath = () => {
|
|
2254
|
+
const currentFileUrl = importMetaUrl;
|
|
2255
|
+
const currentFilePath = url.fileURLToPath(currentFileUrl);
|
|
2256
|
+
const currentDir = path__default.default.dirname(currentFilePath);
|
|
2257
|
+
let packageRoot = currentDir;
|
|
2258
|
+
while (packageRoot !== path__default.default.dirname(packageRoot)) {
|
|
2259
|
+
if (fs__default.default.existsSync(path__default.default.join(packageRoot, "package.json"))) {
|
|
2260
|
+
break;
|
|
2261
|
+
}
|
|
2262
|
+
packageRoot = path__default.default.dirname(packageRoot);
|
|
2263
|
+
}
|
|
2264
|
+
return path__default.default.join(packageRoot, "logs");
|
|
2265
|
+
};
|
|
2266
|
+
var logsPath = getPackageLogsPath();
|
|
2244
2267
|
log4js__default.default.configure({
|
|
2245
2268
|
appenders: {
|
|
2246
2269
|
console: {
|
|
@@ -2252,7 +2275,7 @@ log4js__default.default.configure({
|
|
|
2252
2275
|
},
|
|
2253
2276
|
command: {
|
|
2254
2277
|
type: "dateFile",
|
|
2255
|
-
filename: "
|
|
2278
|
+
filename: path__default.default.join(logsPath, "application", "command"),
|
|
2256
2279
|
pattern: "yyyy-MM-dd.log",
|
|
2257
2280
|
numBackups: 15,
|
|
2258
2281
|
alwaysIncludePattern: true,
|
|
@@ -2261,25 +2284,28 @@ log4js__default.default.configure({
|
|
|
2261
2284
|
pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
|
|
2262
2285
|
}
|
|
2263
2286
|
},
|
|
2264
|
-
|
|
2287
|
+
httpConsole: {
|
|
2265
2288
|
type: "stdout",
|
|
2266
2289
|
layout: {
|
|
2267
2290
|
type: "pattern",
|
|
2268
|
-
pattern: "%[[%d{hh:mm:ss.SSS}][
|
|
2291
|
+
pattern: "%[[amagi][%d{hh:mm:ss.SSS}][HTTP]%] %m"
|
|
2269
2292
|
}
|
|
2270
2293
|
},
|
|
2271
|
-
|
|
2294
|
+
httpRequest: {
|
|
2272
2295
|
type: "dateFile",
|
|
2273
|
-
filename: "
|
|
2296
|
+
filename: path__default.default.join(logsPath, "http", "requests"),
|
|
2274
2297
|
pattern: "yyyy-MM-dd.log",
|
|
2275
|
-
numBackups:
|
|
2298
|
+
numBackups: 30,
|
|
2276
2299
|
alwaysIncludePattern: true,
|
|
2277
|
-
layout: {
|
|
2300
|
+
layout: {
|
|
2301
|
+
type: "pattern",
|
|
2302
|
+
pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
|
|
2303
|
+
}
|
|
2278
2304
|
}
|
|
2279
2305
|
},
|
|
2280
2306
|
categories: {
|
|
2281
|
-
default: { appenders: ["console", "command"], level: "info" }
|
|
2282
|
-
|
|
2307
|
+
default: { appenders: ["console", "command"], level: "info" },
|
|
2308
|
+
http: { appenders: ["httpConsole", "httpRequest"], level: "debug" }
|
|
2283
2309
|
},
|
|
2284
2310
|
pm2: true
|
|
2285
2311
|
});
|
|
@@ -2319,19 +2345,43 @@ var CustomLogger = class {
|
|
|
2319
2345
|
mark(message, ...args) {
|
|
2320
2346
|
this.logger.mark(message, ...args);
|
|
2321
2347
|
}
|
|
2348
|
+
debug(message, ...args) {
|
|
2349
|
+
this.logger.debug(message, ...args);
|
|
2350
|
+
}
|
|
2322
2351
|
};
|
|
2323
2352
|
var logger = new CustomLogger("default");
|
|
2353
|
+
var httpLogger = new CustomLogger("http");
|
|
2324
2354
|
var logMiddleware = (pathsToLog) => {
|
|
2325
2355
|
return (req, res, next) => {
|
|
2326
|
-
if (!pathsToLog || pathsToLog.some((
|
|
2356
|
+
if (!pathsToLog || pathsToLog.some((path2) => req.url.startsWith(path2))) {
|
|
2327
2357
|
const startTime = Date.now();
|
|
2328
2358
|
const url = req.url;
|
|
2329
2359
|
const method = req.method;
|
|
2330
2360
|
const clientIP = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
|
|
2361
|
+
const referer = req.headers["referer"] || req.headers["referrer"] || "-";
|
|
2362
|
+
const contentType = req.headers["content-type"] || "-";
|
|
2363
|
+
const requestSize = req.headers["content-length"] || "0";
|
|
2364
|
+
const protocol = req.protocol;
|
|
2365
|
+
const httpVersion = req.httpVersion;
|
|
2331
2366
|
res.on("finish", () => {
|
|
2332
2367
|
const responseTime = Date.now() - startTime;
|
|
2333
2368
|
const statusCode = res.statusCode;
|
|
2334
|
-
|
|
2369
|
+
const responseSize = res.get("content-length") || "0";
|
|
2370
|
+
const logData = {
|
|
2371
|
+
method,
|
|
2372
|
+
url,
|
|
2373
|
+
statusCode,
|
|
2374
|
+
responseTime: `${responseTime}ms`,
|
|
2375
|
+
clientIP,
|
|
2376
|
+
referer,
|
|
2377
|
+
contentType,
|
|
2378
|
+
requestSize: `${requestSize}B`,
|
|
2379
|
+
responseSize: `${responseSize}B`,
|
|
2380
|
+
protocol,
|
|
2381
|
+
httpVersion,
|
|
2382
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2383
|
+
};
|
|
2384
|
+
httpLogger.debug(JSON.stringify(logData));
|
|
2335
2385
|
});
|
|
2336
2386
|
}
|
|
2337
2387
|
next();
|
|
@@ -2618,6 +2668,7 @@ exports.fetchKuaishouData = fetchKuaishouData;
|
|
|
2618
2668
|
exports.getBilibiliData = getBilibiliData;
|
|
2619
2669
|
exports.getDouyinData = getDouyinData;
|
|
2620
2670
|
exports.getKuaishouData = getKuaishouData;
|
|
2671
|
+
exports.httpLogger = httpLogger;
|
|
2621
2672
|
exports.kuaishou = kuaishou;
|
|
2622
2673
|
exports.kuaishouAPI = kuaishouAPI;
|
|
2623
2674
|
exports.kuaishouApiUrls = kuaishouApiUrls;
|
|
@@ -3,6 +3,9 @@ import crypto from 'crypto';
|
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import { Chalk } from 'chalk';
|
|
5
5
|
import log4js from 'log4js';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import fs from 'fs';
|
|
6
9
|
|
|
7
10
|
// src/platform/bilibili/API.ts
|
|
8
11
|
var BiLiBiLiAPI = class {
|
|
@@ -2230,6 +2233,20 @@ async function getKuaishouData(methodType, arg2, arg3) {
|
|
|
2230
2233
|
var fetchDouyinData = getDouyinData;
|
|
2231
2234
|
var fetchBilibiliData = getBilibiliData;
|
|
2232
2235
|
var fetchKuaishouData = getKuaishouData;
|
|
2236
|
+
var getPackageLogsPath = () => {
|
|
2237
|
+
const currentFileUrl = import.meta.url;
|
|
2238
|
+
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
2239
|
+
const currentDir = path.dirname(currentFilePath);
|
|
2240
|
+
let packageRoot = currentDir;
|
|
2241
|
+
while (packageRoot !== path.dirname(packageRoot)) {
|
|
2242
|
+
if (fs.existsSync(path.join(packageRoot, "package.json"))) {
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
packageRoot = path.dirname(packageRoot);
|
|
2246
|
+
}
|
|
2247
|
+
return path.join(packageRoot, "logs");
|
|
2248
|
+
};
|
|
2249
|
+
var logsPath = getPackageLogsPath();
|
|
2233
2250
|
log4js.configure({
|
|
2234
2251
|
appenders: {
|
|
2235
2252
|
console: {
|
|
@@ -2241,7 +2258,7 @@ log4js.configure({
|
|
|
2241
2258
|
},
|
|
2242
2259
|
command: {
|
|
2243
2260
|
type: "dateFile",
|
|
2244
|
-
filename: "
|
|
2261
|
+
filename: path.join(logsPath, "application", "command"),
|
|
2245
2262
|
pattern: "yyyy-MM-dd.log",
|
|
2246
2263
|
numBackups: 15,
|
|
2247
2264
|
alwaysIncludePattern: true,
|
|
@@ -2250,25 +2267,28 @@ log4js.configure({
|
|
|
2250
2267
|
pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
|
|
2251
2268
|
}
|
|
2252
2269
|
},
|
|
2253
|
-
|
|
2270
|
+
httpConsole: {
|
|
2254
2271
|
type: "stdout",
|
|
2255
2272
|
layout: {
|
|
2256
2273
|
type: "pattern",
|
|
2257
|
-
pattern: "%[[%d{hh:mm:ss.SSS}][
|
|
2274
|
+
pattern: "%[[amagi][%d{hh:mm:ss.SSS}][HTTP]%] %m"
|
|
2258
2275
|
}
|
|
2259
2276
|
},
|
|
2260
|
-
|
|
2277
|
+
httpRequest: {
|
|
2261
2278
|
type: "dateFile",
|
|
2262
|
-
filename: "
|
|
2279
|
+
filename: path.join(logsPath, "http", "requests"),
|
|
2263
2280
|
pattern: "yyyy-MM-dd.log",
|
|
2264
|
-
numBackups:
|
|
2281
|
+
numBackups: 30,
|
|
2265
2282
|
alwaysIncludePattern: true,
|
|
2266
|
-
layout: {
|
|
2283
|
+
layout: {
|
|
2284
|
+
type: "pattern",
|
|
2285
|
+
pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
|
|
2286
|
+
}
|
|
2267
2287
|
}
|
|
2268
2288
|
},
|
|
2269
2289
|
categories: {
|
|
2270
|
-
default: { appenders: ["console", "command"], level: "info" }
|
|
2271
|
-
|
|
2290
|
+
default: { appenders: ["console", "command"], level: "info" },
|
|
2291
|
+
http: { appenders: ["httpConsole", "httpRequest"], level: "debug" }
|
|
2272
2292
|
},
|
|
2273
2293
|
pm2: true
|
|
2274
2294
|
});
|
|
@@ -2308,19 +2328,43 @@ var CustomLogger = class {
|
|
|
2308
2328
|
mark(message, ...args) {
|
|
2309
2329
|
this.logger.mark(message, ...args);
|
|
2310
2330
|
}
|
|
2331
|
+
debug(message, ...args) {
|
|
2332
|
+
this.logger.debug(message, ...args);
|
|
2333
|
+
}
|
|
2311
2334
|
};
|
|
2312
2335
|
var logger = new CustomLogger("default");
|
|
2336
|
+
var httpLogger = new CustomLogger("http");
|
|
2313
2337
|
var logMiddleware = (pathsToLog) => {
|
|
2314
2338
|
return (req, res, next) => {
|
|
2315
|
-
if (!pathsToLog || pathsToLog.some((
|
|
2339
|
+
if (!pathsToLog || pathsToLog.some((path2) => req.url.startsWith(path2))) {
|
|
2316
2340
|
const startTime = Date.now();
|
|
2317
2341
|
const url = req.url;
|
|
2318
2342
|
const method = req.method;
|
|
2319
2343
|
const clientIP = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
|
|
2344
|
+
const referer = req.headers["referer"] || req.headers["referrer"] || "-";
|
|
2345
|
+
const contentType = req.headers["content-type"] || "-";
|
|
2346
|
+
const requestSize = req.headers["content-length"] || "0";
|
|
2347
|
+
const protocol = req.protocol;
|
|
2348
|
+
const httpVersion = req.httpVersion;
|
|
2320
2349
|
res.on("finish", () => {
|
|
2321
2350
|
const responseTime = Date.now() - startTime;
|
|
2322
2351
|
const statusCode = res.statusCode;
|
|
2323
|
-
|
|
2352
|
+
const responseSize = res.get("content-length") || "0";
|
|
2353
|
+
const logData = {
|
|
2354
|
+
method,
|
|
2355
|
+
url,
|
|
2356
|
+
statusCode,
|
|
2357
|
+
responseTime: `${responseTime}ms`,
|
|
2358
|
+
clientIP,
|
|
2359
|
+
referer,
|
|
2360
|
+
contentType,
|
|
2361
|
+
requestSize: `${requestSize}B`,
|
|
2362
|
+
responseSize: `${responseSize}B`,
|
|
2363
|
+
protocol,
|
|
2364
|
+
httpVersion,
|
|
2365
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2366
|
+
};
|
|
2367
|
+
httpLogger.debug(JSON.stringify(logData));
|
|
2324
2368
|
});
|
|
2325
2369
|
}
|
|
2326
2370
|
next();
|
|
@@ -2580,4 +2624,4 @@ var CreateApp = createAmagiClient;
|
|
|
2580
2624
|
var Client = CreateApp;
|
|
2581
2625
|
var amagi = Client;
|
|
2582
2626
|
|
|
2583
|
-
export { BilibiliValidateData, CreateApp, DouyinValidateData, KuaishouAPI, KusiahouValidateData, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
|
2627
|
+
export { BilibiliValidateData, CreateApp, DouyinValidateData, KuaishouAPI, KusiahouValidateData, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, httpLogger, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
package/dist/default/index.d.ts
CHANGED
|
@@ -13479,8 +13479,10 @@ declare class CustomLogger {
|
|
|
13479
13479
|
warn(message: any, ...args: any[]): void;
|
|
13480
13480
|
error(message: any, ...args: any[]): void;
|
|
13481
13481
|
mark(message: any, ...args: any[]): void;
|
|
13482
|
+
debug(message: any, ...args: any[]): void;
|
|
13482
13483
|
}
|
|
13483
13484
|
declare const logger: CustomLogger;
|
|
13485
|
+
declare const httpLogger: CustomLogger;
|
|
13484
13486
|
|
|
13485
13487
|
/**
|
|
13486
13488
|
* 创建一个日志中间件,用于记录特定请求的详细信息
|
|
@@ -14216,8 +14218,8 @@ declare class amagiClient {
|
|
|
14216
14218
|
|
|
14217
14219
|
/** amagi 的构造函数类型 */
|
|
14218
14220
|
type AmagiConstructor = {
|
|
14219
|
-
new (options
|
|
14220
|
-
(options
|
|
14221
|
+
new (options?: cookiesOptions): amagiClient;
|
|
14222
|
+
(options?: cookiesOptions): amagiClient;
|
|
14221
14223
|
/** 抖音相关功能模块 (工具集) */
|
|
14222
14224
|
douyin: typeof douyinUtils;
|
|
14223
14225
|
/** B站相关功能模块 (工具集) */
|
|
@@ -14255,4 +14257,4 @@ declare const CreateApp: AmagiConstructor;
|
|
|
14255
14257
|
declare const Client: AmagiConstructor;
|
|
14256
14258
|
declare const amagi: AmagiConstructor;
|
|
14257
14259
|
|
|
14258
|
-
export { type APIErrorType, type BiliAv2Bv, type BiliBangumiVideoInfo, type BiliBangumiVideoPlayurlIsLogin, type BiliBangumiVideoPlayurlNoLogin, type BiliBiliVideoPlayurlNoLogin, type BiliBv2AV, type BiliCheckQrcode, type BiliDynamicCard, type BiliDynamicInfo, type BiliEmojiList, type BiliLiveRoomDef, type BiliLiveRoomDetail, type BiliNewLoginQrcode, type BiliOneWork, type BiliUserDynamic, type BiliUserFullView, type BiliUserProfile, type BiliVideoPlayurlIsLogin, type BiliWorkComments, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, type BilibiliRequest, BilibiliValidateData, CreateApp, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type DouyinRequest, DouyinValidateData, type DyEmojiList, type DyEmojiProList, type DyImageAlbumWork, type DyMusicWork, type DySearchInfo, type DySlidesWork, type DySuggestWords, type DyUserInfo, type DyUserLiveVideos, type DyUserPostVideos, type DyVideoWork, type DyWorkComments, type KsEmojiList, type KsOneWork, type KsWorkComments, KuaishouAPI, type KuaishouDataOptions, type KuaishouDataOptionsMap, type KuaishouMethodOptionsMap, type KusiahouRequest, KusiahouValidateData, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, type cookiesOptions, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
|
14260
|
+
export { type APIErrorType, type BiliAv2Bv, type BiliBangumiVideoInfo, type BiliBangumiVideoPlayurlIsLogin, type BiliBangumiVideoPlayurlNoLogin, type BiliBiliVideoPlayurlNoLogin, type BiliBv2AV, type BiliCheckQrcode, type BiliDynamicCard, type BiliDynamicInfo, type BiliEmojiList, type BiliLiveRoomDef, type BiliLiveRoomDetail, type BiliNewLoginQrcode, type BiliOneWork, type BiliUserDynamic, type BiliUserFullView, type BiliUserProfile, type BiliVideoPlayurlIsLogin, type BiliWorkComments, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, type BilibiliRequest, BilibiliValidateData, CreateApp, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type DouyinRequest, DouyinValidateData, type DyEmojiList, type DyEmojiProList, type DyImageAlbumWork, type DyMusicWork, type DySearchInfo, type DySlidesWork, type DySuggestWords, type DyUserInfo, type DyUserLiveVideos, type DyUserPostVideos, type DyVideoWork, type DyWorkComments, type KsEmojiList, type KsOneWork, type KsWorkComments, KuaishouAPI, type KuaishouDataOptions, type KuaishouDataOptionsMap, type KuaishouMethodOptionsMap, type KusiahouRequest, KusiahouValidateData, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, type cookiesOptions, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, httpLogger, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|