Commit 43a9976e authored by mingyard's avatar mingyard

feat:获取ars token

parent 5e14298e
......@@ -2,10 +2,12 @@ import { app } from './app';
import { cache } from './cache';
import { database } from './database';
import { deepl } from './deepl';
import { service } from './service';
export const config = {
...app,
cache,
database,
deepl,
service,
};
import { env } from './env';
export interface ServiceConfig {
tts: {
txAsrTokenUrl: string;
};
}
export const service: ServiceConfig = {
tts: {
txAsrTokenUrl: env.TTS_TX_ASR_TOKEN_URL ?? '',
},
};
......@@ -73,4 +73,13 @@ export class AuthController {
async logout(@Req() req: IRequest): Promise<void> {
return await this.authService.logout(req.token, req.decodedToken.exp);
}
// 获取ASR token
@ApiOperation({ summary: '获取ASR token' })
@ApiResponse({ status: 200, description: '获取ASR token成功' })
@Auth()
@Post('getAsrToken')
async getAsrToken(): Promise<any> {
return await this.authService.getTxAsrToken();
}
}
......@@ -15,7 +15,8 @@ import { UserService } from '../user/user.service';
import { InjectRedis } from '@nestjs-modules/ioredis';
import Redis from 'ioredis';
import { MD5 } from '@/common/utils/tool';
import { DecodedToken } from '@/interface';
import { axiosPostRequest } from '@/common/utils/requests/request';
import { config } from '@/config';
@Injectable()
export class AuthService {
......@@ -193,4 +194,17 @@ export class AuthService {
// TODO
return true;
}
// 获取 asr token
async getTxAsrToken(): Promise<any> {
return await axiosPostRequest(
config.service.tts.txAsrTokenUrl,
{},
{
headers: {
'Content-Type': 'application/json',
},
},
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment