feat: more specific fine grain controller

This commit is contained in:
Supan Adit Pratama 2024-11-02 21:39:59 +07:00
parent 80c934b5b2
commit 0c86c9ed88
2 changed files with 43 additions and 11 deletions

View File

@ -23,16 +23,6 @@ Nest Auto CRUD is a library that provides a set of modules, decorator, service,
- Custom body mapping - Custom body mapping
- Custom validation - Custom validation
### Tailored Controller Abstraction
- Controller options for only read and update
- Controller options for only create and delete
- Controller options for only read
- Controller options for only update
- Controller options for only create
- Controller options for only delete
- Controller options for only read and create
### Advanced Support ### Advanced Support
- Generic support for Prisma ORM [#5273](https://github.com/prisma/prisma/issues/5273) - Generic support for Prisma ORM [#5273](https://github.com/prisma/prisma/issues/5273)

View File

@ -35,7 +35,7 @@ import {
ISkeletonUpdateController, ISkeletonUpdateController,
} from './interfaces/controller/skeleton-crud.controller.interface'; } from './interfaces/controller/skeleton-crud.controller.interface';
export class SkeletonReadController implements ISkeletonReadController { export class SkeletonDetailController implements ISkeletonReadController {
constructor( constructor(
@Inject(READ_PROCESS) @Inject(READ_PROCESS)
public readonly readProcess, public readonly readProcess,
@ -71,6 +71,48 @@ export class SkeletonListController implements ISkeletonListController {
} }
} }
export class SkeletonCRController
implements ISkeletonCreateController, ISkeletonReadController
{
constructor(
@Inject(READ_PROCESS)
public readonly readProcess,
@Inject(CREATE_PROCESS)
public readonly createProcess,
) {}
@Get(':id')
async read(@Param('id') identity) {
return await ReadExecutor.bootstrap(this.readProcess, identity);
}
@Post()
async create(@Body() body) {
return await CreateExcutor.bootstrap(this.createProcess, body);
}
}
export class SkeletonURController
implements ISkeletonUpdateController, ISkeletonReadController
{
constructor(
@Inject(READ_PROCESS)
public readonly readProcess,
@Inject(UPDATE_PROCESS)
public readonly updateProcess,
) {}
@Get(':id')
async read(@Param('id') identity) {
return await ReadExecutor.bootstrap(this.readProcess, identity);
}
@Patch(':id')
async update(@Param('id') identity, @Body() body) {
return await UpdateExecutor.bootstrap(this.updateProcess, identity, body);
}
}
export class SkeletonPaginationController export class SkeletonPaginationController
implements ISkeletonPaginationController implements ISkeletonPaginationController
{ {