Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
translation-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinmingyuan
translation-server
Commits
43a9976e
Commit
43a9976e
authored
Jan 11, 2025
by
mingyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:获取ars token
parent
5e14298e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
1 deletion
+39
-1
index.ts
src/config/index.ts
+2
-0
service.ts
src/config/service.ts
+13
-0
auth.controller.ts
src/controller/auth/auth.controller.ts
+9
-0
auth.service.ts
src/controller/auth/auth.service.ts
+15
-1
No files found.
src/config/index.ts
View file @
43a9976e
...
@@ -2,10 +2,12 @@ import { app } from './app';
...
@@ -2,10 +2,12 @@ import { app } from './app';
import
{
cache
}
from
'./cache'
;
import
{
cache
}
from
'./cache'
;
import
{
database
}
from
'./database'
;
import
{
database
}
from
'./database'
;
import
{
deepl
}
from
'./deepl'
;
import
{
deepl
}
from
'./deepl'
;
import
{
service
}
from
'./service'
;
export
const
config
=
{
export
const
config
=
{
...
app
,
...
app
,
cache
,
cache
,
database
,
database
,
deepl
,
deepl
,
service
,
};
};
src/config/service.ts
0 → 100644
View file @
43a9976e
import
{
env
}
from
'./env'
;
export
interface
ServiceConfig
{
tts
:
{
txAsrTokenUrl
:
string
;
};
}
export
const
service
:
ServiceConfig
=
{
tts
:
{
txAsrTokenUrl
:
env
.
TTS_TX_ASR_TOKEN_URL
??
''
,
},
};
src/controller/auth/auth.controller.ts
View file @
43a9976e
...
@@ -73,4 +73,13 @@ export class AuthController {
...
@@ -73,4 +73,13 @@ export class AuthController {
async
logout
(@
Req
()
req
:
IRequest
):
Promise
<
void
>
{
async
logout
(@
Req
()
req
:
IRequest
):
Promise
<
void
>
{
return
await
this
.
authService
.
logout
(
req
.
token
,
req
.
decodedToken
.
exp
);
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
();
}
}
}
src/controller/auth/auth.service.ts
View file @
43a9976e
...
@@ -15,7 +15,8 @@ import { UserService } from '../user/user.service';
...
@@ -15,7 +15,8 @@ import { UserService } from '../user/user.service';
import
{
InjectRedis
}
from
'@nestjs-modules/ioredis'
;
import
{
InjectRedis
}
from
'@nestjs-modules/ioredis'
;
import
Redis
from
'ioredis'
;
import
Redis
from
'ioredis'
;
import
{
MD5
}
from
'@/common/utils/tool'
;
import
{
MD5
}
from
'@/common/utils/tool'
;
import
{
DecodedToken
}
from
'@/interface'
;
import
{
axiosPostRequest
}
from
'@/common/utils/requests/request'
;
import
{
config
}
from
'@/config'
;
@
Injectable
()
@
Injectable
()
export
class
AuthService
{
export
class
AuthService
{
...
@@ -193,4 +194,17 @@ export class AuthService {
...
@@ -193,4 +194,17 @@ export class AuthService {
// TODO
// TODO
return
true
;
return
true
;
}
}
// 获取 asr token
async
getTxAsrToken
():
Promise
<
any
>
{
return
await
axiosPostRequest
(
config
.
service
.
tts
.
txAsrTokenUrl
,
{},
{
headers
:
{
'Content-Type'
:
'application/json'
,
},
},
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment