@ikenxuan/amagi 1.5.2 → 1.5.3
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/lib/model/dir.d.ts +5 -0
- package/lib/model/dir.js +9 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +1 -0
- package/lib/server/client.js +5 -4
- package/package.json +1 -1
package/lib/model/dir.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
/** 当前文件的绝对路径 */
|
|
4
|
+
const filePath = fileURLToPath(import.meta.url).replace(/\\/g, '/');
|
|
5
|
+
/** 插件包绝对路径 */
|
|
6
|
+
const dirPath = path.resolve(filePath, '../../../');
|
|
7
|
+
/** 插件包的名称 */
|
|
8
|
+
const basename = path.basename(dirPath);
|
|
9
|
+
export { dirPath, basename };
|
package/lib/model/index.d.ts
CHANGED
package/lib/model/index.js
CHANGED
package/lib/server/client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import fastify from 'fastify';
|
|
2
|
-
import { DouyinResult } from '../business/douyin/index.js';
|
|
3
1
|
import { BilibiliResult } from '../business/bilibili/index.js';
|
|
4
|
-
import
|
|
2
|
+
import { DouyinResult } from '../business/douyin/index.js';
|
|
3
|
+
import fastify from 'fastify';
|
|
5
4
|
import fastifySwaggerUi from '@fastify/swagger-ui';
|
|
5
|
+
import fastifySwagger from '@fastify/swagger';
|
|
6
|
+
import { dirPath } from '../model/index.js';
|
|
6
7
|
import fs from 'node:fs';
|
|
7
8
|
export class client {
|
|
8
9
|
douyin;
|
|
@@ -24,7 +25,7 @@ export class client {
|
|
|
24
25
|
*/
|
|
25
26
|
async initServer(log = false) {
|
|
26
27
|
const client = fastify({ logger: log });
|
|
27
|
-
const data = JSON.parse(fs.readFileSync(
|
|
28
|
+
const data = JSON.parse(fs.readFileSync(dirPath + '/amagi.openapi.json', 'utf8'));
|
|
28
29
|
await client.register(fastifySwagger, {
|
|
29
30
|
openapi: data
|
|
30
31
|
});
|