From 3d7370d73a77f8009746f33f5a84f67c19d0a269 Mon Sep 17 00:00:00 2001 From: imeepos Date: Mon, 8 Sep 2025 13:41:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=99=8D=E7=BA=A7=E6=8A=96?= =?UTF-8?q?=E9=9F=B3SDK=E7=89=88=E6=9C=AC=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 降级@open-dy/open_api_sdk从1.1.3到1.1.2解决兼容性问题 - 优化import顺序,移动HttpModule和JwtModule到顶部 - 移除未使用的TemplateController导入 - 修复TypeScript配置,改用commonjs模块系统 - 添加DouyinAuthClient文件到版本控制 --- package.json | 2 +- pnpm-lock.yaml | 10 +++---- src/app.module.ts | 4 +-- .../adapters/DouYinClient.ts | 30 +++++++++++++++++++ src/main.ts | 1 - tsconfig.json | 5 ++-- 6 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 src/content-moderation/adapters/DouYinClient.ts diff --git a/package.json b/package.json index 6365d76..4fb2aab 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@nestjs/swagger": "^11.2.0", "@nestjs/typeorm": "^11.0.0", "@open-dy/open_api_credential": "^1.0.0", - "@open-dy/open_api_sdk": "^1.1.3", + "@open-dy/open_api_sdk": "1.1.2", "axios": "^1.11.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5283bdf..481f5c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,8 +36,8 @@ importers: specifier: ^1.0.0 version: 1.0.0 '@open-dy/open_api_sdk': - specifier: ^1.1.3 - version: 1.1.3 + specifier: 1.1.2 + version: 1.1.2 axios: specifier: ^1.11.0 version: 1.11.0 @@ -819,8 +819,8 @@ packages: '@open-dy/open_api_credential@1.0.0': resolution: {integrity: sha512-MmLrJL2QFYHV3RNJ2/hQEXcjzBCa6mtklW+AJXG+xS/x8cJ7/AgW3wQjvNwJ0oMRyxch1nQ10h9EnOGr1kew0g==} - '@open-dy/open_api_sdk@1.1.3': - resolution: {integrity: sha512-N04K4zkfa5tadbo+iz0ZCdHvNq+9sdzwWZzP4OX0rEmba0VXVlYstzjFpvYsTp+nQcJqab2DvyaXhShJfO1/rg==} + '@open-dy/open_api_sdk@1.1.2': + resolution: {integrity: sha512-Z+TzDxzFf+25Hw6E3crKLNRrFrN45I+BrfmnxPHm0QpGHO284FmvbEaug1lXq480jD32kPZMjJQR+r5d8LYW9g==} '@open-dy/open_api_util@1.0.1': resolution: {integrity: sha512-vgUTsyNqB0mtn0LclEr7J2E0eoXTHym1Xh4hO5gXXGYS4MoZGpu9IbYlkR4LMVUSOmJs5ZhRxmNqvEt4D/5fLg==} @@ -4263,7 +4263,7 @@ snapshots: transitivePeerDependencies: - debug - '@open-dy/open_api_sdk@1.1.3': + '@open-dy/open_api_sdk@1.1.2': dependencies: '@alicloud/tea-typescript': 1.8.0 '@open-dy/open_api_credential': 1.0.0 diff --git a/src/app.module.ts b/src/app.module.ts index c401ae2..7d281e3 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,6 +1,8 @@ import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { TypeOrmModule } from '@nestjs/typeorm'; +import { HttpModule } from '@nestjs/axios'; +import { JwtModule } from '@nestjs/jwt'; import { AppController } from './app.controller'; import { TemplateService } from './templates/index'; import { TemplateManager } from './templates/types'; @@ -17,8 +19,6 @@ import { N8nTemplateFactoryService } from './services/n8n-template-factory.servi import { TemplateController } from './controllers/template.controller'; import { PlatformModule } from './platform/platform.module'; import { ContentModerationModule } from './content-moderation/content-moderation.module'; -import { HttpModule } from '@nestjs/axios'; -import { JwtModule } from '@nestjs/jwt'; @Module({ imports: [ diff --git a/src/content-moderation/adapters/DouYinClient.ts b/src/content-moderation/adapters/DouYinClient.ts new file mode 100644 index 0000000..07ec628 --- /dev/null +++ b/src/content-moderation/adapters/DouYinClient.ts @@ -0,0 +1,30 @@ +import { Injectable } from "@nestjs/common"; +import { ConfigService } from "@nestjs/config"; +import Client from '@open-dy/open_api_credential'; + +/** + +名称 描述 +HTTP URL https://open.douyin.com/oauth/access_token/ +HTTP Method POST + +content-type: application/x-www-form-urlencoded" +body: +- client_key +- client_secret + */ + +@Injectable() +export class DouyinAuthClient { + private readonly client: Client; + constructor(private config: ConfigService) { + this.client = new Client({ + clientKey: this.config.get('BYTEDANCE_APP_ID') || '', + clientSecret: this.config.get('BYTEDANCE_APP_SECRET') || '', + }) + } + + getAccessToken() { + return this.client.getAccessToken() + } +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 679669b..433a6b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ import { NestFactory } from '@nestjs/core'; import { ValidationPipe } from '@nestjs/common'; import { AppModule } from './app.module'; import { setupSwagger } from './config/swagger.config'; -import { TemplateController } from './controllers/template.controller'; async function bootstrap() { const app = await NestFactory.create(AppModule); diff --git a/tsconfig.json b/tsconfig.json index 044d6e2..37841e0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,7 @@ { "compilerOptions": { - "module": "nodenext", - "moduleResolution": "nodenext", - "resolvePackageJsonExports": true, + "module": "commonjs", + "moduleResolution": "node", "esModuleInterop": true, "isolatedModules": true, "declaration": true,