mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-24 12:56:22 +00:00
feat: custom process modification
This commit is contained in:
parent
0c86c9ed88
commit
55fe243e00
@ -1,19 +1,14 @@
|
||||
import { PrismaService } from '../prisma.service';
|
||||
import {
|
||||
PrismaCreateProcess,
|
||||
PrismaDeleteProcess,
|
||||
PrismaPaginationProcess,
|
||||
PrismaReadProcess,
|
||||
PrismaUpdateProcess,
|
||||
} from '../processes';
|
||||
import { PrismaListProcess } from '../processes/list.process';
|
||||
|
||||
// @TODO: Find way to use typesafe in each of the process property
|
||||
// Known Issue:
|
||||
// - You cannot be able modified the constructor extended to each process
|
||||
export interface PrismaModuleOptions {
|
||||
delegate: (prisma: PrismaService) => unknown;
|
||||
processCreate?: typeof PrismaCreateProcess;
|
||||
processDelete?: typeof PrismaDeleteProcess;
|
||||
processList?: typeof PrismaListProcess;
|
||||
processPagination?: typeof PrismaPaginationProcess;
|
||||
processRead?: typeof PrismaReadProcess;
|
||||
processUpdate?: typeof PrismaUpdateProcess;
|
||||
delegate: (prisma: PrismaService) => any;
|
||||
processCreate?;
|
||||
processDelete?;
|
||||
processList?;
|
||||
processPagination?;
|
||||
processRead?;
|
||||
processUpdate?;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaModule } from 'libs';
|
||||
import { CustomController } from './custom.controller';
|
||||
import { CustomListProcess } from './domain/custom.list.process';
|
||||
import { CustomReadProcess } from './domain/custom.read.process';
|
||||
|
@ -1,9 +1,25 @@
|
||||
import { PrismaReadProcess } from '@aditama-labs/nest-autocrud/prisma';
|
||||
import {
|
||||
PRISMA_DELEGATE,
|
||||
PrismaReadProcess,
|
||||
PrismaService,
|
||||
} from '@aditama-labs/nest-autocrud/prisma';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class CustomReadProcess extends PrismaReadProcess {
|
||||
constructor(
|
||||
@Inject(PRISMA_DELEGATE)
|
||||
delegate,
|
||||
@Inject()
|
||||
private prisma: PrismaService,
|
||||
) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
customResult;
|
||||
|
||||
async before(): Promise<any> {
|
||||
console.log(await this.prisma.user.findMany());
|
||||
console.log('The ID requested in path parameter', this.identityData);
|
||||
}
|
||||
async after(): Promise<any> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaModule } from 'libs';
|
||||
import { SimpleController } from './simple.controller';
|
||||
|
||||
@Module({
|
||||
|
Loading…
Reference in New Issue
Block a user