You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

2 years ago
import { Module } from '@nestjs/common'
import { UsersModule } from 'src/users/users.module'
import { PassportModule } from '@nestjs/passport'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { AuthController } from './auth.controller'
import { FtStrategy } from './42.strategy'
import { SessionSerializer } from './session.serializer'
import { JwtModule } from '@nestjs/jwt'
import { MailerModule } from '@nestjs-modules/mailer'
import { AuthService } from './auth.service'
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter'
2 years ago
const mailUser =
2 years ago
process.env.MAIL_USER !== null && process.env.MAIL_USER !== ''
2 years ago
? process.env.MAIL_USER
2 years ago
: ''
const mailPass =
2 years ago
process.env.MAIL_PASSWORD !== null && process.env.MAIL_PASSWORD !== ''
2 years ago
? process.env.MAIL_PASSWORD
2 years ago
: ''
@Module({
2 years ago
imports: [
UsersModule,
PassportModule,
ConfigModule.forRoot(),
JwtModule.register({
secret: process.env.JWT_SECRET,
2 years ago
signOptions: { expiresIn: '60s' }
2 years ago
}),
MailerModule.forRoot({
transport: {
2 years ago
service: 'gmail',
2 years ago
auth: {
user: mailUser,
2 years ago
pass: mailPass
}
2 years ago
},
template: {
2 years ago
dir: 'src/auth/mails',
2 years ago
adapter: new HandlebarsAdapter(),
options: {
2 years ago
strict: true
}
2 years ago
},
defaults: {
2 years ago
from: '"No Reply" vaganiwast@gmail.com'
}
})
2 years ago
],
providers: [ConfigService, FtStrategy, SessionSerializer, AuthService],
2 years ago
controllers: [AuthController]
})
export class AuthModule {}