mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-24 21:16:21 +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 { 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 {
|
export interface PrismaModuleOptions {
|
||||||
delegate: (prisma: PrismaService) => unknown;
|
delegate: (prisma: PrismaService) => any;
|
||||||
processCreate?: typeof PrismaCreateProcess;
|
processCreate?;
|
||||||
processDelete?: typeof PrismaDeleteProcess;
|
processDelete?;
|
||||||
processList?: typeof PrismaListProcess;
|
processList?;
|
||||||
processPagination?: typeof PrismaPaginationProcess;
|
processPagination?;
|
||||||
processRead?: typeof PrismaReadProcess;
|
processRead?;
|
||||||
processUpdate?: typeof PrismaUpdateProcess;
|
processUpdate?;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
import { PrismaModule } from 'libs';
|
|
||||||
import { CustomController } from './custom.controller';
|
import { CustomController } from './custom.controller';
|
||||||
import { CustomListProcess } from './domain/custom.list.process';
|
import { CustomListProcess } from './domain/custom.list.process';
|
||||||
import { CustomReadProcess } from './domain/custom.read.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 {
|
export class CustomReadProcess extends PrismaReadProcess {
|
||||||
|
constructor(
|
||||||
|
@Inject(PRISMA_DELEGATE)
|
||||||
|
delegate,
|
||||||
|
@Inject()
|
||||||
|
private prisma: PrismaService,
|
||||||
|
) {
|
||||||
|
super(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
customResult;
|
customResult;
|
||||||
|
|
||||||
async before(): Promise<any> {
|
async before(): Promise<any> {
|
||||||
|
console.log(await this.prisma.user.findMany());
|
||||||
console.log('The ID requested in path parameter', this.identityData);
|
console.log('The ID requested in path parameter', this.identityData);
|
||||||
}
|
}
|
||||||
async after(): Promise<any> {
|
async after(): Promise<any> {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { PrismaModule } from '@aditama-labs/nest-autocrud/prisma';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
import { PrismaModule } from 'libs';
|
|
||||||
import { SimpleController } from './simple.controller';
|
import { SimpleController } from './simple.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
Loading…
Reference in New Issue
Block a user