refactor: 降级抖音SDK版本并优化项目配置

- 降级@open-dy/open_api_sdk从1.1.3到1.1.2解决兼容性问题
- 优化import顺序,移动HttpModule和JwtModule到顶部
- 移除未使用的TemplateController导入
- 修复TypeScript配置,改用commonjs模块系统
- 添加DouyinAuthClient文件到版本控制
This commit is contained in:
imeepos 2025-09-08 13:41:24 +08:00
parent 39f2ecc4f5
commit 3d7370d73a
6 changed files with 40 additions and 12 deletions

View File

@ -39,7 +39,7 @@
"@nestjs/swagger": "^11.2.0", "@nestjs/swagger": "^11.2.0",
"@nestjs/typeorm": "^11.0.0", "@nestjs/typeorm": "^11.0.0",
"@open-dy/open_api_credential": "^1.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", "axios": "^1.11.0",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.14.2", "class-validator": "^0.14.2",

View File

@ -36,8 +36,8 @@ importers:
specifier: ^1.0.0 specifier: ^1.0.0
version: 1.0.0 version: 1.0.0
'@open-dy/open_api_sdk': '@open-dy/open_api_sdk':
specifier: ^1.1.3 specifier: 1.1.2
version: 1.1.3 version: 1.1.2
axios: axios:
specifier: ^1.11.0 specifier: ^1.11.0
version: 1.11.0 version: 1.11.0
@ -819,8 +819,8 @@ packages:
'@open-dy/open_api_credential@1.0.0': '@open-dy/open_api_credential@1.0.0':
resolution: {integrity: sha512-MmLrJL2QFYHV3RNJ2/hQEXcjzBCa6mtklW+AJXG+xS/x8cJ7/AgW3wQjvNwJ0oMRyxch1nQ10h9EnOGr1kew0g==} resolution: {integrity: sha512-MmLrJL2QFYHV3RNJ2/hQEXcjzBCa6mtklW+AJXG+xS/x8cJ7/AgW3wQjvNwJ0oMRyxch1nQ10h9EnOGr1kew0g==}
'@open-dy/open_api_sdk@1.1.3': '@open-dy/open_api_sdk@1.1.2':
resolution: {integrity: sha512-N04K4zkfa5tadbo+iz0ZCdHvNq+9sdzwWZzP4OX0rEmba0VXVlYstzjFpvYsTp+nQcJqab2DvyaXhShJfO1/rg==} resolution: {integrity: sha512-Z+TzDxzFf+25Hw6E3crKLNRrFrN45I+BrfmnxPHm0QpGHO284FmvbEaug1lXq480jD32kPZMjJQR+r5d8LYW9g==}
'@open-dy/open_api_util@1.0.1': '@open-dy/open_api_util@1.0.1':
resolution: {integrity: sha512-vgUTsyNqB0mtn0LclEr7J2E0eoXTHym1Xh4hO5gXXGYS4MoZGpu9IbYlkR4LMVUSOmJs5ZhRxmNqvEt4D/5fLg==} resolution: {integrity: sha512-vgUTsyNqB0mtn0LclEr7J2E0eoXTHym1Xh4hO5gXXGYS4MoZGpu9IbYlkR4LMVUSOmJs5ZhRxmNqvEt4D/5fLg==}
@ -4263,7 +4263,7 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- debug - debug
'@open-dy/open_api_sdk@1.1.3': '@open-dy/open_api_sdk@1.1.2':
dependencies: dependencies:
'@alicloud/tea-typescript': 1.8.0 '@alicloud/tea-typescript': 1.8.0
'@open-dy/open_api_credential': 1.0.0 '@open-dy/open_api_credential': 1.0.0

View File

@ -1,6 +1,8 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config'; import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { HttpModule } from '@nestjs/axios';
import { JwtModule } from '@nestjs/jwt';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { TemplateService } from './templates/index'; import { TemplateService } from './templates/index';
import { TemplateManager } from './templates/types'; import { TemplateManager } from './templates/types';
@ -17,8 +19,6 @@ import { N8nTemplateFactoryService } from './services/n8n-template-factory.servi
import { TemplateController } from './controllers/template.controller'; import { TemplateController } from './controllers/template.controller';
import { PlatformModule } from './platform/platform.module'; import { PlatformModule } from './platform/platform.module';
import { ContentModerationModule } from './content-moderation/content-moderation.module'; import { ContentModerationModule } from './content-moderation/content-moderation.module';
import { HttpModule } from '@nestjs/axios';
import { JwtModule } from '@nestjs/jwt';
@Module({ @Module({
imports: [ imports: [

View File

@ -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()
}
}

View File

@ -2,7 +2,6 @@ import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { setupSwagger } from './config/swagger.config'; import { setupSwagger } from './config/swagger.config';
import { TemplateController } from './controllers/template.controller';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);

View File

@ -1,8 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "nodenext", "module": "commonjs",
"moduleResolution": "nodenext", "moduleResolution": "node",
"resolvePackageJsonExports": true,
"esModuleInterop": true, "esModuleInterop": true,
"isolatedModules": true, "isolatedModules": true,
"declaration": true, "declaration": true,