Skip to content

Commit

Permalink
apply env (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: NHT <[email protected]>
  • Loading branch information
nfesta2023 and hoangtuan910 authored Mar 3, 2024
1 parent 85a69a8 commit 877b173
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"printWidth": 80
}
33 changes: 18 additions & 15 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,31 @@ import { OtpService } from './service/otp.service';
import { CustomerService } from './service/customer.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Customer } from './entity/customer.entity';
import { ConfigModule } from '@nestjs/config';
import { ConfigModule, ConfigService } from '@nestjs/config';
// import { redisStore } from 'cache-manager-redis-yet';
import { CacheModule } from '@nestjs/cache-manager';
import { HttpModule } from '@nestjs/axios';

@Module({
imports: [
TypeOrmModule.forRoot({
type: 'mysql',
host: 'db-2all-free.c9s4w6ey6i0r.ap-southeast-1.rds.amazonaws.com',
port: 3306,
username: 'admin',
password: 'Goodfood4goodlife',
database: 'new-2all-dev',
entities: [Customer],
synchronize: false,
autoLoadEntities: true,
ConfigModule.forRoot({
envFilePath: ['.env'],
}),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
type: 'mysql',
host: configService.get<string>('DB_HOST'),
port: configService.get<number>('DB_PORT'),
username: configService.get<string>('DB_USERNAME'),
password: configService.get<string>('DB_PASSWORD'),
database: configService.get<string>('DB_NAME'),
entities: [__dirname + '/entity/*.entity{.ts,.js}'],
synchronize: false,
autoLoadEntities: true,
}),
inject: [ConfigService],
}),
ConfigModule.forRoot(),
CacheModule.registerAsync({
isGlobal: true,
useFactory: async () => ({
Expand All @@ -38,9 +44,6 @@ import { HttpModule } from '@nestjs/axios';
}),
TypeOrmModule.forFeature([Customer]),
HttpModule,
ConfigModule.forRoot({
envFilePath: ['.env'],
}),
],
controllers: [AppController, TokenController, OtpController],
providers: [
Expand Down

0 comments on commit 877b173

Please sign in to comment.