feat: wip migrate server to nestjs

This commit is contained in:
Ahmed Bouhuolia
2024-11-12 23:08:51 +02:00
parent f5834c72c6
commit 19080a67ab
94 changed files with 7587 additions and 98 deletions

View File

@@ -0,0 +1,24 @@
import { Knex } from 'knex';
import { Global, Module, Scope } from '@nestjs/common';
import { TENANCY_DB_CONNECTION } from '../TenancyDB/TenancyDB.constants';
import { Item } from '../../../modules/Items/models/Item';
import { Account } from '@/modules/Accounts/models/Account';
const models = [Item, Account];
const modelProviders = models.map((model) => {
return {
provide: model.name,
inject: [TENANCY_DB_CONNECTION],
scope: Scope.REQUEST,
useFactory: async (tenantKnex: Knex) => {
return model.bindKnex(tenantKnex);
},
};
});
@Global()
@Module({
providers: [...modelProviders],
exports: [...modelProviders],
})
export class TenancyModelsModule {}