diff --git a/libs/auth/application/src/lib/auth.service.ts b/libs/auth/application/src/lib/auth.service.ts index acef393..9412771 100644 --- a/libs/auth/application/src/lib/auth.service.ts +++ b/libs/auth/application/src/lib/auth.service.ts @@ -3,6 +3,7 @@ import { UsersService } from '@users/application'; import { JwtService } from '@nestjs/jwt'; import { AwsCognitoService } from '@shared/infrastructure-aws-cognito'; +// Implement the authentication logic export class AuthService { constructor( private awsCognitoService: AwsCognitoService, @@ -11,6 +12,7 @@ export class AuthService { private readonly logger = new Logger(AuthService.name), ) {} + // Retrieving a user and verifying the password async signIn( email: string, pass: string, diff --git a/libs/auth/interface-adapters/src/lib/auth.module.ts b/libs/auth/interface-adapters/src/lib/auth.module.ts index 2fe248f..f1d7b84 100644 --- a/libs/auth/interface-adapters/src/lib/auth.module.ts +++ b/libs/auth/interface-adapters/src/lib/auth.module.ts @@ -1,10 +1,27 @@ import { AuthService } from '@auth/application'; import { Module } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; +import { JwtModule } from '@nestjs/jwt'; +import { UsersModule } from '@users/interface-adapters'; import { AuthResolver } from './resolver/auth.resolver'; @Module({ + imports: [ + UsersModule, + JwtModule.registerAsync({ + global: true, + useFactory: (configService: ConfigService) => { + const jwtConfig = configService.get('jwt'); + return { + secret: jwtConfig.secret, + signOptions: { expiresIn: '60s' }, + }; + }, + inject: [ConfigService], + }), + ], providers: [AuthResolver, AuthService], - exports: [], + exports: [AuthService], }) export class AuthModule {} diff --git a/libs/auth/interface-adapters/src/lib/resolver/auth.resolver.ts b/libs/auth/interface-adapters/src/lib/resolver/auth.resolver.ts index bee6ba9..39dad6e 100644 --- a/libs/auth/interface-adapters/src/lib/resolver/auth.resolver.ts +++ b/libs/auth/interface-adapters/src/lib/resolver/auth.resolver.ts @@ -3,6 +3,7 @@ import { Resolver, Mutation, Args } from '@nestjs/graphql'; import { SignInInputDto } from '../dto/sign-in-input.dto'; +// Expose the authentication endpoints @Resolver() export class AuthResolver { constructor(private authService: AuthService) {}