- Add functions to convert between UTC and Beijing time in timezone utility. - Update BidsService to return latest update and publish dates in Beijing time. - Modify BidCrawlerService to store publish dates in UTC format. - Change database timezone configuration to UTC for consistency.
29 lines
1018 B
TypeScript
29 lines
1018 B
TypeScript
import { Module } from '@nestjs/common';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
|
|
@Module({
|
|
imports: [
|
|
TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => ({
|
|
type:
|
|
(configService.get<string>('DATABASE_TYPE', 'mariadb') as
|
|
| 'mariadb'
|
|
| 'mysql'
|
|
| 'postgres') || 'mariadb',
|
|
host: configService.get<string>('DATABASE_HOST', 'localhost'),
|
|
port: configService.get<number>('DATABASE_PORT', 3306),
|
|
username: configService.get<string>('DATABASE_USERNAME', 'root'),
|
|
password: configService.get<string>('DATABASE_PASSWORD', 'root'),
|
|
database: configService.get<string>('DATABASE_NAME', 'bidding'),
|
|
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
|
|
synchronize: false,
|
|
timezone: 'Z',
|
|
}),
|
|
}),
|
|
],
|
|
})
|
|
export class DatabaseModule {}
|