Skip to content

Instantly share code, notes, and snippets.

@zzpzaf
Created January 23, 2022 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzpzaf/27ce9f2847ce01952e510ff70d1edb3c to your computer and use it in GitHub Desktop.
Save zzpzaf/27ce9f2847ce01952e510ff70d1edb3c to your computer and use it in GitHub Desktop.
Unexpected behavior when getting a value from .env file for expireIn property - auth.module.ts
auth.module.ts
import { forwardRef, Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { UsersModule } from 'src/users/users.module';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
@Module({
imports: [
forwardRef(() => UsersModule),
JwtModule.registerAsync({
// imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
secret: configService.get('JWT_SECRET'),
signOptions: {
expiresIn: configService.get<number>('JWT_EXP_H', 60),
},
}),
}),
],
controllers: [AuthController],
providers: [AuthService],
exports: [JwtModule],
})
export class AuthModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment