2020-02-01 16:11:48 +01:00
|
|
|
import { Module } from "@nestjs/common";
|
|
|
|
|
import { ConfigService } from "@nestjs/config";
|
|
|
|
|
import { JwtModule } from "@nestjs/jwt";
|
|
|
|
|
import { PassportModule } from "@nestjs/passport";
|
|
|
|
|
import { UsersModule } from "../users/users.module";
|
|
|
|
|
import { AuthController } from "./auth.controller";
|
|
|
|
|
import { AuthService } from "./auth.service";
|
|
|
|
|
import { JwtStrategy } from "./jwt.strategy";
|
|
|
|
|
import { SpotifyStrategy } from "./spotify.strategy";
|
|
|
|
|
|
|
|
|
|
@Module({
|
|
|
|
|
imports: [
|
|
|
|
|
PassportModule.register({ defaultStrategy: "jwt" }),
|
|
|
|
|
JwtModule.registerAsync({
|
|
|
|
|
useFactory: (config: ConfigService) => ({
|
|
|
|
|
secret: config.get<string>("JWT_SECRET"),
|
2020-05-03 20:57:03 +02:00
|
|
|
signOptions: {
|
|
|
|
|
expiresIn: config.get<string>("JWT_EXPIRATION_TIME"),
|
|
|
|
|
algorithm: config.get("JWT_ALGORITHM"),
|
|
|
|
|
},
|
2020-02-01 16:11:48 +01:00
|
|
|
}),
|
2020-05-02 17:17:20 +02:00
|
|
|
inject: [ConfigService],
|
2020-02-01 16:11:48 +01:00
|
|
|
}),
|
2020-05-02 17:17:20 +02:00
|
|
|
UsersModule,
|
2020-02-01 16:11:48 +01:00
|
|
|
],
|
|
|
|
|
providers: [AuthService, SpotifyStrategy, JwtStrategy],
|
|
|
|
|
exports: [PassportModule],
|
2020-05-02 17:17:20 +02:00
|
|
|
controllers: [AuthController],
|
2020-02-01 16:11:48 +01:00
|
|
|
})
|
|
|
|
|
export class AuthModule {}
|