Skip to content

Commit fbee009

Browse files
committed
update
1 parent a7023e0 commit fbee009

File tree

7 files changed

+26
-20
lines changed

7 files changed

+26
-20
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/dist
33
/node_modules
44
.env
5-
docker-compose.ym
5+
docker-compose.yml
66
# Logs
77
logs
88
*.log
@@ -34,3 +34,5 @@ lerna-debug.log*
3434
!.vscode/tasks.json
3535
!.vscode/launch.json
3636
!.vscode/extensions.json
37+
docker/docker-compose.yml
38+
docker/docker-compose.yml

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN apt clean -y \
2222
&& export LC_ALL=${LC_ALL} \
2323
&& locale-gen ${LANG} \
2424
&& dpkg-reconfigure --frontend ${DEBIAN_FRONTEND} locales \
25-
&& apt install --no-install-recommends -yq supervisor
25+
&& apt install --no-install-recommends -yq procps supervisor
2626

2727
WORKDIR /data
2828
#RUN npm i -g @nestjs/cli

docker/docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ services:
1414
- "9229:9229"
1515
networks:
1616
- dev
17-
redis:
17+
sesame-redis:
1818
image: redis
19+
container_name: sesame-redis
1920
restart: always
2021
networks:
2122
- dev
2223
ports:
23-
- "6380:6379"
24+
- "6379:6379"
2425
command: redis-server --appendonly yes
2526
networks:
2627
dev:

src/app.module.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ import { AppService } from './app.service';
44
import { PasswdModule } from './passwd/passwd.module';
55
import { BullModule } from '@nestjs/bullmq';
66
import { AuthModule } from './auth/auth.module';
7+
import {ConfigModule, ConfigService} from '@nestjs/config';
8+
9+
import config from './config'
710

811
@Module({
9-
imports: [PasswdModule,
10-
BullModule.forRoot({connection: {host:'redis',port:6379}}),
12+
imports: [
13+
ConfigModule.forRoot({
14+
load: [config]
15+
}),
16+
PasswdModule,
1117
AuthModule]
1218
})
1319
export class AppModule {}

src/passwd/passwd.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class PasswdController {
2424
@ApiBearerAuth()
2525
@UseGuards(AuthGuard("api-key"))
2626
async change(@Body() cpwd: ChangePasswordDto,@Res() res: Response): Promise<Response>{
27+
this.logger.log('call passwd')
2728
const data= await this.passwdService.change(cpwd)
2829
console.log(data)
2930
data.data.uid=cpwd.uid

src/passwd/passwd.module.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { Module } from '@nestjs/common';
22
import { PasswdService } from './passwd.service';
33
import { PasswdController } from './passwd.controller';
4-
import {BullModule} from "@nestjs/bullmq";
4+
import {ConfigModule} from "@nestjs/config";
55

66
@Module({
7-
imports: [PasswdModule,
8-
BullModule.registerQueue(
9-
{
10-
name: 'backend',
11-
connection: {host:'redis',port:6379}}
12-
)
7+
imports: [PasswdModule,ConfigModule
138
],
149
controllers: [PasswdController],
1510
providers: [PasswdService],

src/passwd/passwd.service.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { Injectable } from '@nestjs/common';
22
import {ChangePasswordDto} from "./dto/change-password.dto";
33
import {InjectQueue} from "@nestjs/bullmq";
4-
import {Job, Queue,QueueEvents} from 'bullmq'
4+
import { Queue,QueueEvents} from 'bullmq'
5+
import { ConfigService } from '@nestjs/config';
56
@Injectable()
67
export class PasswdService {
7-
constructor(@InjectQueue('backend') private backendQueue: Queue){}
88

9+
constructor(private readonly configService:ConfigService){}
910
async change(passwd:ChangePasswordDto) {
10-
const queueEvents = new QueueEvents('backend',{connection: {host:'redis',port:6379}})
11-
const job=await this.backendQueue.add('CHANGEPWD',passwd)
11+
const redisConfig={host:this.configService.get('redis.host'),port:this.configService.get('redis.port')}
12+
const queue=new Queue(this.configService.get('nameQueue'),{connection:redisConfig})
13+
const queueEvents = new QueueEvents(this.configService.get('nameQueue'),{connection: redisConfig})
14+
const job=await queue.add('CHANGEPWD',passwd)
1215
queueEvents.on('failed',(errors)=>{
1316
console.log(errors)
1417
})
15-
return await job.waitUntilFinished(queueEvents)
16-
17-
18+
return await job.waitUntilFinished(queueEvents,30000)
1819
}
1920
}
2021

0 commit comments

Comments
 (0)