diff --git a/libs/prisma/src/constants.ts b/libs/prisma/src/constants.ts index eff4044..ef30a81 100644 --- a/libs/prisma/src/constants.ts +++ b/libs/prisma/src/constants.ts @@ -1 +1 @@ -export declare const PRISMA_DELEGATE = 'PRISMA_DELEGATE'; +export const PRISMA_DELEGATE = 'PRISMA_DELEGATE'; diff --git a/libs/prisma/src/prisma.module.ts b/libs/prisma/src/prisma.module.ts index 4da3cab..ec0ce32 100644 --- a/libs/prisma/src/prisma.module.ts +++ b/libs/prisma/src/prisma.module.ts @@ -1,14 +1,8 @@ -import { READ_ENTIRE_PROCESS } from '@autocrud/skeleton'; import { Module } from '@nestjs/common'; import { PrismaService } from './prisma.service'; -import { PrismaListProcess } from './processes/list.process'; @Module({ - providers: [ - PrismaService, - { provide: READ_ENTIRE_PROCESS, useClass: PrismaListProcess }, - , - ], + providers: [PrismaService], exports: [PrismaService], }) export class PrismaModule {} diff --git a/libs/prisma/src/processes/list.process.ts b/libs/prisma/src/processes/list.process.ts index 9243f5f..8a9cbf5 100644 --- a/libs/prisma/src/processes/list.process.ts +++ b/libs/prisma/src/processes/list.process.ts @@ -2,7 +2,7 @@ import { ListProcess } from '@autocrud/skeleton/processes/list.process'; import { PrismaProcess } from './prisma.process'; export class PrismaListProcess extends PrismaProcess implements ListProcess { - private data; + private data: any; async process(): Promise { this.data = await this.getDelegate().findMany(); diff --git a/libs/prisma/src/processes/prisma.process.ts b/libs/prisma/src/processes/prisma.process.ts index ba1175a..e771a20 100644 --- a/libs/prisma/src/processes/prisma.process.ts +++ b/libs/prisma/src/processes/prisma.process.ts @@ -1,16 +1,17 @@ import { DefaultProcess } from '@autocrud/skeleton/processes/default.process'; -import { Inject } from '@nestjs/common'; +import { Inject, Injectable } from '@nestjs/common'; import { PRISMA_DELEGATE } from '../constants'; +@Injectable() export class PrismaProcess extends DefaultProcess { constructor( @Inject(PRISMA_DELEGATE) - private delegate: any, + private delegate, ) { super(); } - get getDelegate() { + getDelegate() { return this.delegate; } } diff --git a/libs/skeleton/src/constants.ts b/libs/skeleton/src/constants.ts index b637760..3da889d 100644 --- a/libs/skeleton/src/constants.ts +++ b/libs/skeleton/src/constants.ts @@ -1 +1 @@ -export declare const READ_ENTIRE_PROCESS = 'READ_ENTIRE_PROCESS'; +export const READ_ENTIRE_PROCESS = 'READ_ENTIRE_PROCESS'; diff --git a/src/app.module.ts b/src/app.module.ts index c8ced0a..058b675 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,13 @@ import { PrismaModule, PrismaService } from '@autocrud/prisma'; import { PRISMA_DELEGATE } from '@autocrud/prisma/constants'; +import { ListProcess } from '@autocrud/skeleton/processes/list.process'; import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; +import { READ_ENTIRE_PROCESS } from '@autocrud/skeleton'; +import { PrismaListProcess } from '@autocrud/prisma/processes/list.process'; -const delegateFactory = { +const customFactory = { provide: PRISMA_DELEGATE, useFactory: (prisma: PrismaService) => { return prisma.user; @@ -13,8 +16,13 @@ const delegateFactory = { }; @Module({ - imports: [PrismaModule], + imports: [], controllers: [AppController], - providers: [AppService, delegateFactory], + providers: [ + AppService, + PrismaService, + customFactory, + { provide: READ_ENTIRE_PROCESS, useClass: PrismaListProcess }, + ], }) export class AppModule {}