@ikenxuan/amagi 4.4.7-pr103.ca19953 → 4.4.8
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 +27 -27
- package/dist/default/esm/index.mjs +26 -26
- package/dist/default/index.d.ts +9 -7
- package/package.json +19 -1
|
@@ -4,17 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var axios = require('axios');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
|
+
var express = require('express');
|
|
7
8
|
var chalk = require('chalk');
|
|
8
9
|
var log4js = require('log4js');
|
|
9
|
-
var express = require('express');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
13
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
14
14
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
15
|
+
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
15
16
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
16
17
|
var log4js__default = /*#__PURE__*/_interopDefault(log4js);
|
|
17
|
-
var express__default = /*#__PURE__*/_interopDefault(express);
|
|
18
18
|
|
|
19
19
|
// src/platform/bilibili/API.ts
|
|
20
20
|
var BiLiBiLiAPI = class {
|
|
@@ -535,9 +535,8 @@ async function wbi_sign(BASEURL, cookie) {
|
|
|
535
535
|
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
536
536
|
return query;
|
|
537
537
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
var registerBilibiliRoutes = (router, cookie) => {
|
|
538
|
+
var registerBilibiliRoutes = (cookie) => {
|
|
539
|
+
const router = express__default.default.Router();
|
|
541
540
|
router.get("/new_login_qrcode", async (req, res) => {
|
|
542
541
|
const data2 = await BilibiliData({
|
|
543
542
|
methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
|
|
@@ -1384,9 +1383,8 @@ async function GlobalGetData2(options) {
|
|
|
1384
1383
|
}
|
|
1385
1384
|
return ResponseData;
|
|
1386
1385
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
var registerDouyinRoutes = (router, cookie) => {
|
|
1386
|
+
var registerDouyinRoutes = (cookie) => {
|
|
1387
|
+
const router = express__default.default.Router();
|
|
1390
1388
|
router.get("/fetch_one_work", async (req, res) => {
|
|
1391
1389
|
const data2 = await DouyinData({
|
|
1392
1390
|
methodType: "\u805A\u5408\u89E3\u6790",
|
|
@@ -1590,9 +1588,8 @@ async function GlobalGetData3(options) {
|
|
|
1590
1588
|
}
|
|
1591
1589
|
return ResponseData;
|
|
1592
1590
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
var registerKuaishouRoutes = (router, cookie) => {
|
|
1591
|
+
var registerKuaishouRoutes = (cookie) => {
|
|
1592
|
+
const router = express__default.default.Router();
|
|
1596
1593
|
router.get("/fetch_one_work", async (req, res) => {
|
|
1597
1594
|
const data2 = await KuaishouData({
|
|
1598
1595
|
methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
|
|
@@ -1739,17 +1736,21 @@ var CustomLogger = class {
|
|
|
1739
1736
|
}
|
|
1740
1737
|
};
|
|
1741
1738
|
var logger = new CustomLogger("default");
|
|
1742
|
-
var logMiddleware = (
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1739
|
+
var logMiddleware = (pathsToLog) => {
|
|
1740
|
+
return (req, res, next) => {
|
|
1741
|
+
if (!pathsToLog || pathsToLog.some((path) => req.url.startsWith(path))) {
|
|
1742
|
+
const startTime = Date.now();
|
|
1743
|
+
const url = req.url;
|
|
1744
|
+
const method = req.method;
|
|
1745
|
+
const clientIP = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
|
|
1746
|
+
res.on("finish", () => {
|
|
1747
|
+
const responseTime = Date.now() - startTime;
|
|
1748
|
+
const statusCode = res.statusCode;
|
|
1749
|
+
logger.info(`[${method}] ${url} (Status: ${statusCode}, Time: ${responseTime}ms, Client: ${clientIP})`);
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
next();
|
|
1753
|
+
};
|
|
1753
1754
|
};
|
|
1754
1755
|
var Networks = class {
|
|
1755
1756
|
url;
|
|
@@ -1932,17 +1933,16 @@ var amagi = class {
|
|
|
1932
1933
|
*/
|
|
1933
1934
|
startClient(port = 4567) {
|
|
1934
1935
|
const app = express__default.default();
|
|
1935
|
-
const router = express.Router();
|
|
1936
1936
|
app.get("/", (_req, res) => {
|
|
1937
1937
|
res.redirect(301, "https://amagi.apifox.cn");
|
|
1938
1938
|
});
|
|
1939
1939
|
app.get("/docs", (_req, res) => {
|
|
1940
1940
|
res.redirect(301, "https://amagi.apifox.cn");
|
|
1941
1941
|
});
|
|
1942
|
-
app.use("/api/
|
|
1943
|
-
app.use("/api/douyin", registerDouyinRoutes(
|
|
1944
|
-
app.use("/api/bilibili", registerBilibiliRoutes(
|
|
1945
|
-
app.use(
|
|
1942
|
+
app.use(logMiddleware(["/api/douyin", "/api/bilibili", "/api/kuaishou"]));
|
|
1943
|
+
app.use("/api/douyin", registerDouyinRoutes(this.douyin));
|
|
1944
|
+
app.use("/api/bilibili", registerBilibiliRoutes(this.bilibili));
|
|
1945
|
+
app.use("/api/kuaishou", registerKuaishouRoutes(this.kuaishou));
|
|
1946
1946
|
app.listen(port, "::", () => {
|
|
1947
1947
|
logger.mark(`Amagi server listening on ${logger.green(`http://localhost:${port}`)} ${logger.yellow("API docs: https://amagi.apifox.cn ")}`);
|
|
1948
1948
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import axios, { AxiosError } from 'axios';
|
|
2
2
|
import crypto from 'crypto';
|
|
3
|
+
import express from 'express';
|
|
3
4
|
import chalk from 'chalk';
|
|
4
5
|
import log4js from 'log4js';
|
|
5
|
-
import express, { Router } from 'express';
|
|
6
6
|
|
|
7
7
|
// src/platform/bilibili/API.ts
|
|
8
8
|
var BiLiBiLiAPI = class {
|
|
@@ -523,9 +523,8 @@ async function wbi_sign(BASEURL, cookie) {
|
|
|
523
523
|
const query = encWbi(params, web_keys.img_key, web_keys.sub_key);
|
|
524
524
|
return query;
|
|
525
525
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
var registerBilibiliRoutes = (router, cookie) => {
|
|
526
|
+
var registerBilibiliRoutes = (cookie) => {
|
|
527
|
+
const router = express.Router();
|
|
529
528
|
router.get("/new_login_qrcode", async (req, res) => {
|
|
530
529
|
const data2 = await BilibiliData({
|
|
531
530
|
methodType: "\u7533\u8BF7\u4E8C\u7EF4\u7801"
|
|
@@ -1372,9 +1371,8 @@ async function GlobalGetData2(options) {
|
|
|
1372
1371
|
}
|
|
1373
1372
|
return ResponseData;
|
|
1374
1373
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
var registerDouyinRoutes = (router, cookie) => {
|
|
1374
|
+
var registerDouyinRoutes = (cookie) => {
|
|
1375
|
+
const router = express.Router();
|
|
1378
1376
|
router.get("/fetch_one_work", async (req, res) => {
|
|
1379
1377
|
const data2 = await DouyinData({
|
|
1380
1378
|
methodType: "\u805A\u5408\u89E3\u6790",
|
|
@@ -1578,9 +1576,8 @@ async function GlobalGetData3(options) {
|
|
|
1578
1576
|
}
|
|
1579
1577
|
return ResponseData;
|
|
1580
1578
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
var registerKuaishouRoutes = (router, cookie) => {
|
|
1579
|
+
var registerKuaishouRoutes = (cookie) => {
|
|
1580
|
+
const router = express.Router();
|
|
1584
1581
|
router.get("/fetch_one_work", async (req, res) => {
|
|
1585
1582
|
const data2 = await KuaishouData({
|
|
1586
1583
|
methodType: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
|
|
@@ -1727,17 +1724,21 @@ var CustomLogger = class {
|
|
|
1727
1724
|
}
|
|
1728
1725
|
};
|
|
1729
1726
|
var logger = new CustomLogger("default");
|
|
1730
|
-
var logMiddleware = (
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1727
|
+
var logMiddleware = (pathsToLog) => {
|
|
1728
|
+
return (req, res, next) => {
|
|
1729
|
+
if (!pathsToLog || pathsToLog.some((path) => req.url.startsWith(path))) {
|
|
1730
|
+
const startTime = Date.now();
|
|
1731
|
+
const url = req.url;
|
|
1732
|
+
const method = req.method;
|
|
1733
|
+
const clientIP = req.headers["x-forwarded-for"] || req.socket.remoteAddress;
|
|
1734
|
+
res.on("finish", () => {
|
|
1735
|
+
const responseTime = Date.now() - startTime;
|
|
1736
|
+
const statusCode = res.statusCode;
|
|
1737
|
+
logger.info(`[${method}] ${url} (Status: ${statusCode}, Time: ${responseTime}ms, Client: ${clientIP})`);
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
next();
|
|
1741
|
+
};
|
|
1741
1742
|
};
|
|
1742
1743
|
var Networks = class {
|
|
1743
1744
|
url;
|
|
@@ -1920,17 +1921,16 @@ var amagi = class {
|
|
|
1920
1921
|
*/
|
|
1921
1922
|
startClient(port = 4567) {
|
|
1922
1923
|
const app = express();
|
|
1923
|
-
const router = Router();
|
|
1924
1924
|
app.get("/", (_req, res) => {
|
|
1925
1925
|
res.redirect(301, "https://amagi.apifox.cn");
|
|
1926
1926
|
});
|
|
1927
1927
|
app.get("/docs", (_req, res) => {
|
|
1928
1928
|
res.redirect(301, "https://amagi.apifox.cn");
|
|
1929
1929
|
});
|
|
1930
|
-
app.use("/api/
|
|
1931
|
-
app.use("/api/douyin", registerDouyinRoutes(
|
|
1932
|
-
app.use("/api/bilibili", registerBilibiliRoutes(
|
|
1933
|
-
app.use(
|
|
1930
|
+
app.use(logMiddleware(["/api/douyin", "/api/bilibili", "/api/kuaishou"]));
|
|
1931
|
+
app.use("/api/douyin", registerDouyinRoutes(this.douyin));
|
|
1932
|
+
app.use("/api/bilibili", registerBilibiliRoutes(this.bilibili));
|
|
1933
|
+
app.use("/api/kuaishou", registerKuaishouRoutes(this.kuaishou));
|
|
1934
1934
|
app.listen(port, "::", () => {
|
|
1935
1935
|
logger.mark(`Amagi server listening on ${logger.green(`http://localhost:${port}`)} ${logger.yellow("API docs: https://amagi.apifox.cn ")}`);
|
|
1936
1936
|
});
|
package/dist/default/index.d.ts
CHANGED
|
@@ -13664,7 +13664,12 @@ declare class CustomLogger {
|
|
|
13664
13664
|
}
|
|
13665
13665
|
declare const logger: CustomLogger;
|
|
13666
13666
|
|
|
13667
|
-
|
|
13667
|
+
/**
|
|
13668
|
+
* 创建一个日志中间件,用于记录特定请求的详细信息
|
|
13669
|
+
* @param pathsToLog 指定需要记录日志的请求路径数组如果未提供,则记录所有请求的日志
|
|
13670
|
+
* @returns
|
|
13671
|
+
*/
|
|
13672
|
+
declare const logMiddleware: (pathsToLog?: string[]) => RequestHandler;
|
|
13668
13673
|
|
|
13669
13674
|
interface HeadersObject {
|
|
13670
13675
|
[key: string]: string;
|
|
@@ -13769,10 +13774,9 @@ interface BilibiliRequest<T extends keyof BilibiliDataOptionsMap> extends Reques
|
|
|
13769
13774
|
}
|
|
13770
13775
|
/**
|
|
13771
13776
|
* 注册B站相关的API接口路由
|
|
13772
|
-
* @param router - 路由实例
|
|
13773
13777
|
* @param cookie - 有效的cookie
|
|
13774
13778
|
*/
|
|
13775
|
-
declare const registerBilibiliRoutes: (
|
|
13779
|
+
declare const registerBilibiliRoutes: (cookie: string) => Router;
|
|
13776
13780
|
|
|
13777
13781
|
declare function av2bv(aid: number): `BV1${string}`;
|
|
13778
13782
|
declare function bv2av(bvid: string): number;
|
|
@@ -13816,10 +13820,9 @@ interface DouyinRequest<T extends keyof DouyinDataOptionsMap> extends Request {
|
|
|
13816
13820
|
}
|
|
13817
13821
|
/**
|
|
13818
13822
|
* 注册抖音相关的API接口路由
|
|
13819
|
-
* @param router - 路由实例
|
|
13820
13823
|
* @param cookie - 有效的cookie
|
|
13821
13824
|
*/
|
|
13822
|
-
declare const registerDouyinRoutes: (
|
|
13825
|
+
declare const registerDouyinRoutes: (cookie: string) => Router;
|
|
13823
13826
|
|
|
13824
13827
|
type KuaishouMethodOptionsWithoutMethodType = {
|
|
13825
13828
|
[K in keyof KuaishouMethodOptionsMap]: OmitMethodType<KuaishouMethodOptionsMap[K]>;
|
|
@@ -13875,10 +13878,9 @@ interface KusiahouRequest<T extends keyof KuaishouDataOptionsMap> extends Reques
|
|
|
13875
13878
|
}
|
|
13876
13879
|
/**
|
|
13877
13880
|
* 注册快手相关的API接口路由
|
|
13878
|
-
* @param router - 路由实例
|
|
13879
13881
|
* @param cookie - 有效的cookie
|
|
13880
13882
|
*/
|
|
13881
|
-
declare const registerKuaishouRoutes: (
|
|
13883
|
+
declare const registerKuaishouRoutes: (cookie: string) => Router;
|
|
13882
13884
|
|
|
13883
13885
|
type ckParams = {
|
|
13884
13886
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikenxuan/amagi",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.8",
|
|
4
4
|
"description": "抖音、B站的 web 端相关数据接口基于 Node.js 的实现",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"douyin",
|
|
@@ -62,6 +62,24 @@
|
|
|
62
62
|
"log4js": "6.9.0",
|
|
63
63
|
"pino-pretty": "^13.0.0"
|
|
64
64
|
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@eslint/js": "^9.17.0",
|
|
67
|
+
"@swc/core": "^1.10.12",
|
|
68
|
+
"@types/express": "^4.17.21",
|
|
69
|
+
"@types/lodash": "^4.17.13",
|
|
70
|
+
"@types/node": "^22.10.2",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
72
|
+
"@typescript-eslint/parser": "^8.18.1",
|
|
73
|
+
"eslint": "^9.17.0",
|
|
74
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
75
|
+
"globals": "^15.14.0",
|
|
76
|
+
"neostandard": "^0.12.0",
|
|
77
|
+
"sort-package-json": "^2.12.0",
|
|
78
|
+
"tsc-alias": "^1.8.10",
|
|
79
|
+
"tsup": "^8.3.6",
|
|
80
|
+
"tsx": "^4.19.2",
|
|
81
|
+
"typescript": "^5.7.2"
|
|
82
|
+
},
|
|
65
83
|
"publishConfig": {
|
|
66
84
|
"access": "public",
|
|
67
85
|
"registry": "https://registry.npmjs.org"
|