Skip to content

Commit

Permalink
fix: fixed required review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Homoakin619 committed Jul 23, 2024
1 parent 359cd2e commit 46c2dcb
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 24 deletions.
11 changes: 0 additions & 11 deletions config/appConfig.ts

This file was deleted.

5 changes: 5 additions & 0 deletions config/auth.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { registerAs } from '@nestjs/config';
export default registerAs('auth', () => ({
jwtSecret: process.env.JWT_SECRET,
jwtExpiry: process.env.JWT_EXPIRY_TIMEFRAME,
}));
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"lint-staged": "^15.2.5",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.4",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
Expand Down Expand Up @@ -104,4 +103,4 @@
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
}
3 changes: 2 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SeedingModule } from './database/seeding/seeding.module';
import HealthController from './health.controller';
import { AuthModule } from './modules/auth/auth.module';
import { UserModule } from './modules/user/user.module';
import authConfig from 'config/auth.config';

@Module({
providers: [
Expand All @@ -36,7 +37,7 @@ import { UserModule } from './modules/user/user.module';
*/
envFilePath: ['.env.development.local', `.env.${process.env.PROFILE}`],
isGlobal: true,
load: [serverConfig],
load: [serverConfig, authConfig],
/**
* See ".env.local" file to list all environment variables needed by the app
*/
Expand Down
7 changes: 4 additions & 3 deletions src/modules/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from '../user/entities/user.entity';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { appConfig } from '../../../config/appConfig';
import appConfig from '../../../config/auth.config';
import { Repository } from 'typeorm';
import AuthenticationService from './auth.service';
import UserService from '../user/user.service';



@Module({
controllers: [RegistrationController],
providers: [AuthenticationService, Repository, UserService],
Expand All @@ -18,8 +19,8 @@ import UserService from '../user/user.service';
PassportModule,
JwtModule.register({
global: true,
secret: appConfig.jwt.jwtSecret,
signOptions: { expiresIn: `${appConfig.jwt.jwtExpiry}s` },
secret: (appConfig()).jwtSecret,
signOptions: { expiresIn: `${(appConfig()).jwtExpiry}s` },
}),
],
})
Expand Down
2 changes: 1 addition & 1 deletion src/modules/user/dto/user-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import UserInterface from "../interfaces/UserInterface";

type UserResponseDTO = Pick<UserInterface, "email" | "first_name" | "last_name" | "id" | "is_active" | "attempts_left" | "created_at" | "updated_at">
type UserResponseDTO = Partial<UserInterface>
export default UserResponseDTO
8 changes: 4 additions & 4 deletions src/modules/user/options/UserIdentifierOptions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type UserIdentifierOptions = {
type UserIdentifierOptionsType = {
identifierType: "id",
identifier: string
} |
{
} |
{
identifierType: "email",
identifier: string
}

export default UserIdentifierOptions
export default UserIdentifierOptionsType
4 changes: 2 additions & 2 deletions src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { User } from './entities/user.entity';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import CreateNewUserOptions from './options/CreateNewUserOptions';
import UserIdentifierOptions from './options/UserIdentifierOptions';
import UserIdentifierOptionsType from './options/UserIdentifierOptions';
import UserResponseDTO from './dto/user-response.dto';


Expand All @@ -30,7 +30,7 @@ export default class UserService {
return user
}

async getUserRecord(identifierOptions: UserIdentifierOptions) {
async getUserRecord(identifierOptions: UserIdentifierOptionsType) {
const { identifier, identifierType } = identifierOptions

const GetRecord = {
Expand Down

0 comments on commit 46c2dcb

Please sign in to comment.