diff --git a/packages/server/src/app.module.ts b/packages/server/src/app.module.ts index 0b1b8ea..9461ebc 100644 --- a/packages/server/src/app.module.ts +++ b/packages/server/src/app.module.ts @@ -10,6 +10,7 @@ import { join } from 'path'; import { ConfigModule } from '@nestjs/config'; import { InviteModule } from './invite/invite.module'; import { NotificationModule } from './notification/notification.module'; +import { JwtModule } from './jwt/jwt.module'; @Module({ imports: [ @@ -26,7 +27,8 @@ import { NotificationModule } from './notification/notification.module'; } }), InviteModule, - NotificationModule + NotificationModule, + JwtModule ] }) export class AppModule implements NestModule { diff --git a/packages/server/src/auth/auth.module.ts b/packages/server/src/auth/auth.module.ts index 014f0e5..f4f2cb2 100644 --- a/packages/server/src/auth/auth.module.ts +++ b/packages/server/src/auth/auth.module.ts @@ -4,33 +4,12 @@ import { AuthService } from './auth.service'; import { AuthResolver } from './auth.resolver'; import { PrismaService } from '../prisma/prisma.service'; import { UserModule } from '../user/user.module'; -import { JwtModule, JwtModuleOptions } from '@nestjs/jwt'; -import { ConfigModule, ConfigService } from '@nestjs/config'; import { ProjectModule } from '../project/project.module'; import { NotificationModule } from '../notification/notification.module'; +import { JwtModule } from '../jwt/jwt.module'; @Module({ - imports: [ - UserModule, - ProjectModule, - NotificationModule, - JwtModule.registerAsync({ - imports: [ConfigModule], - useFactory: async (configService: ConfigService) => { - const options: JwtModuleOptions = { - privateKey: configService.get('PRIVATE_KEY'), - publicKey: configService.get('PUBLIC_KEY_1'), - signOptions: { - expiresIn: configService.get('JWT_EXPIRATION'), - issuer: 'https://sail.bu.edu', - algorithm: 'RS256' - } - }; - return options; - }, - inject: [ConfigService] - }) - ], + imports: [UserModule, ProjectModule, NotificationModule, JwtModule], controllers: [LoginController, SignupController, RecoveryController, PublicKeyController], providers: [AuthResolver, AuthService, PrismaService], exports: [AuthService] diff --git a/packages/server/src/invite/invite.module.ts b/packages/server/src/invite/invite.module.ts index bb76bdb..ecb09d7 100644 --- a/packages/server/src/invite/invite.module.ts +++ b/packages/server/src/invite/invite.module.ts @@ -5,9 +5,10 @@ import { PrismaService } from '../prisma/prisma.service'; import { UserModule } from '../user/user.module'; import { NotificationModule } from '../notification/notification.module'; import { AuthModule } from '../auth/auth.module'; +import { JwtModule } from '../jwt/jwt.module'; @Module({ - imports: [UserModule, NotificationModule, AuthModule], + imports: [UserModule, NotificationModule, AuthModule, JwtModule], providers: [InviteService, InviteResolver, PrismaService], exports: [InviteService] }) diff --git a/packages/server/src/jwt/jwt.module.ts b/packages/server/src/jwt/jwt.module.ts new file mode 100644 index 0000000..467f3f5 --- /dev/null +++ b/packages/server/src/jwt/jwt.module.ts @@ -0,0 +1,26 @@ +import { Module } from '@nestjs/common'; +import { ConfigModule, ConfigService } from '@nestjs/config'; +import { JwtModule as NestJwtModule, JwtModuleOptions } from '@nestjs/jwt'; + +@Module({ + imports: [ + NestJwtModule.registerAsync({ + imports: [ConfigModule], + useFactory: async (configService: ConfigService) => { + const options: JwtModuleOptions = { + privateKey: configService.get('PRIVATE_KEY'), + publicKey: configService.get('PUBLIC_KEY_1'), + signOptions: { + expiresIn: configService.get('JWT_EXPIRATION'), + issuer: 'https://sail.bu.edu', + algorithm: 'RS256' + } + }; + return options; + }, + inject: [ConfigService] + }) + ], + exports: [NestJwtModule] +}) +export class JwtModule {} diff --git a/packages/server/src/user/user.module.ts b/packages/server/src/user/user.module.ts index 40f473b..60fd4cb 100644 --- a/packages/server/src/user/user.module.ts +++ b/packages/server/src/user/user.module.ts @@ -1,12 +1,12 @@ import { Module } from '@nestjs/common'; -import { JwtModule } from '@nestjs/jwt'; import { UserController } from './user.controller'; import { UserService } from './user.service'; import { PrismaService } from '../prisma/prisma.service'; import { UserResolver } from './user.resolver'; +import { JwtModule } from '../jwt/jwt.module'; @Module({ - imports: [JwtModule.register({ secret: process.env.SECRET })], + imports: [JwtModule], controllers: [UserController], providers: [UserService, PrismaService, UserResolver], exports: [UserService]