34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { Module } from '@nestjs/common'
|
|
import { PassportModule } from '@nestjs/passport'
|
|
import { JwtModule } from '@nestjs/jwt'
|
|
import { ConfigModule, ConfigService } from '@nestjs/config'
|
|
import { MembershipModule } from '../membership/membership.module'
|
|
import { AuthService, RANDOM_FN_TOKEN } from './auth.service'
|
|
import { AuthController } from './auth.controller'
|
|
import { WechatService } from './wechat.service'
|
|
import { JwtStrategy } from './jwt.strategy'
|
|
import { JwtAuthGuard } from './jwt-auth.guard'
|
|
import { RolesGuard } from './roles.guard'
|
|
import { InviteModule } from '../invite/invite.module'
|
|
|
|
@Module({
|
|
imports: [
|
|
PassportModule,
|
|
InviteModule,
|
|
ConfigModule,
|
|
MembershipModule,
|
|
JwtModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => ({
|
|
secret: configService.getOrThrow<string>('JWT_SECRET'),
|
|
signOptions: { expiresIn: '7d' },
|
|
}),
|
|
}),
|
|
],
|
|
controllers: [AuthController],
|
|
providers: [AuthService, WechatService, JwtStrategy, JwtAuthGuard, RolesGuard, { provide: RANDOM_FN_TOKEN, useValue: Math.random }],
|
|
exports: [JwtStrategy, JwtAuthGuard, RolesGuard, AuthService],
|
|
})
|
|
export class AuthModule {}
|