feat: simplify the providers

This commit is contained in:
Supan Adit Pratama 2024-10-27 00:50:15 +07:00
parent 231fd12dea
commit 9187f02a23
2 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,12 @@
import { READ_ENTIRE_PROCESS } from '@autocrud/skeleton';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { PrismaService } from './prisma.service'; import { PrismaService } from './prisma.service';
import { PrismaListProcess } from './processes/list.process';
export const configServiceProvider = {
provide: READ_ENTIRE_PROCESS,
useClass: PrismaListProcess,
};
@Module({ @Module({
providers: [PrismaService], providers: [PrismaService],

View File

@ -1,11 +1,12 @@
import { PrismaModule, PrismaService } from '@autocrud/prisma'; import {
configServiceProvider,
PrismaModule,
PrismaService,
} from '@autocrud/prisma';
import { PRISMA_DELEGATE } from '@autocrud/prisma/constants'; import { PRISMA_DELEGATE } from '@autocrud/prisma/constants';
import { ListProcess } from '@autocrud/skeleton/processes/list.process';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { READ_ENTIRE_PROCESS } from '@autocrud/skeleton';
import { PrismaListProcess } from '@autocrud/prisma/processes/list.process';
const customFactory = { const customFactory = {
provide: PRISMA_DELEGATE, provide: PRISMA_DELEGATE,
@ -16,13 +17,8 @@ const customFactory = {
}; };
@Module({ @Module({
imports: [], imports: [PrismaModule],
controllers: [AppController], controllers: [AppController],
providers: [ providers: [AppService, customFactory, configServiceProvider],
AppService,
PrismaService,
customFactory,
{ provide: READ_ENTIRE_PROCESS, useClass: PrismaListProcess },
],
}) })
export class AppModule {} export class AppModule {}