File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 11import { Sequelize } from 'sequelize-typescript' ;
22import { User } from './../users/user.entity' ;
3+ import { ConfigService } from './../shared/config/config.service' ;
34
45export const databaseProviders = [
56 {
67 provide : 'SEQUELIZE' ,
7- useFactory : async ( ) => {
8- const sequelize = new Sequelize ( {
9- dialect : 'postgres' ,
10- host : 'localhost' ,
11- port : 5432 ,
12- username : 'postgres' ,
13- password : 'postgres' ,
14- database : 'nest' ,
15- } ) ;
8+ useFactory : async ( configService : ConfigService ) => {
9+ const sequelize = new Sequelize ( configService . sequelizeOrmConfig ) ;
1610 sequelize . addModels ( [ User ] ) ;
1711 await sequelize . sync ( ) ;
1812 return sequelize ;
1913 } ,
14+ inject : [ ConfigService ] ,
2015 } ,
2116] ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { UserLoginResponseDto } from './dto/user-login-response.dto';
88import { JwtPayload } from './auth/jwt-payload.model' ;
99import { sign } from 'jsonwebtoken' ;
1010import { UpdateUserDto } from './dto/update-user.dto' ;
11+ import { ConfigService } from './../shared/config/config.service' ;
1112
1213@Injectable ( )
1314export class UsersService {
@@ -16,8 +17,9 @@ export class UsersService {
1617 constructor (
1718 @Inject ( 'UsersRepository' )
1819 private readonly usersRepository : typeof User ,
20+ private readonly configService : ConfigService ,
1921 ) {
20- this . jwtPrivateKey = 'jwtPrivateKey' ;
22+ this . jwtPrivateKey = this . configService . jwtConfig . privateKey ;
2123 }
2224
2325 async findAll ( ) : Promise < UserDto [ ] > {
You can’t perform that action at this time.
0 commit comments