mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat: wip migrate server to nestjs
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import Knex from 'knex';
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import {
|
||||
SystemKnexConnection,
|
||||
SystemKnexConnectionConfigure,
|
||||
} from './SystemDB.constants';
|
||||
import { SystemDatabaseController } from './SystemDB.controller';
|
||||
import { knexSnakeCaseMappers } from 'objection';
|
||||
|
||||
const providers = [
|
||||
{
|
||||
provide: SystemKnexConnectionConfigure,
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
client: configService.get('systemDatabase.client'),
|
||||
connection: {
|
||||
host: configService.get('systemDatabase.host'),
|
||||
user: configService.get('systemDatabase.user'),
|
||||
password: configService.get('systemDatabase.password'),
|
||||
database: configService.get('systemDatabase.databaseName'),
|
||||
charset: 'utf8',
|
||||
},
|
||||
migrations: {
|
||||
directory: configService.get('systemDatabase.migrationDir'),
|
||||
},
|
||||
seeds: {
|
||||
directory: configService.get('systemDatabase.seedsDir'),
|
||||
},
|
||||
pool: { min: 0, max: 7 },
|
||||
...knexSnakeCaseMappers({ upperCase: true }),
|
||||
}),
|
||||
},
|
||||
{
|
||||
provide: SystemKnexConnection,
|
||||
inject: [SystemKnexConnectionConfigure],
|
||||
useFactory: (knexConfig) => {
|
||||
return Knex(knexConfig);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [...providers],
|
||||
exports: [...providers],
|
||||
controllers: [SystemDatabaseController],
|
||||
})
|
||||
export class SystemDatabaseModule {}
|
||||
Reference in New Issue
Block a user