chore: refacto NestJS in modules (#308)
* chore: wip refacto in modules * fix: rollback port * fix: jwt guard in wrong folder * chore: rename folder exception-filter in filters * fix: tests are running * fix: excessive stack depth comparing types * fix: auth issue * chore: move createUser in UserService * fix: test * fix: guards * fix: jwt guard don't handle falsy user
This commit is contained in:
31
server/src/core/auth/auth.module.ts
Normal file
31
server/src/core/auth/auth.module.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { JwtAuthStrategy } from './strategies/jwt.auth.strategy';
|
||||
import { AuthService } from './services/auth.service';
|
||||
import { GoogleAuthController } from './google.auth.controller';
|
||||
import { GoogleStrategy } from './strategies/google.auth.strategy';
|
||||
import { TokenController } from './token.controller';
|
||||
import { PrismaService } from 'src/database/prisma.service';
|
||||
import { UserModule } from '../user/user.module';
|
||||
|
||||
const jwtModule = JwtModule.registerAsync({
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
return {
|
||||
secret: configService.get<string>('JWT_SECRET'),
|
||||
signOptions: {
|
||||
expiresIn: configService.get<string>('JWT_EXPIRES_IN') + 's',
|
||||
},
|
||||
};
|
||||
},
|
||||
imports: [ConfigModule.forRoot({})],
|
||||
inject: [ConfigService],
|
||||
});
|
||||
|
||||
@Module({
|
||||
imports: [jwtModule, ConfigModule.forRoot({}), UserModule],
|
||||
controllers: [GoogleAuthController, TokenController],
|
||||
providers: [AuthService, JwtAuthStrategy, GoogleStrategy, PrismaService],
|
||||
exports: [jwtModule],
|
||||
})
|
||||
export class AuthModule {}
|
||||
Reference in New Issue
Block a user