feat: rename AutoCRUDController to CustomCRUDController

This commit is contained in:
Supan Adit Pratama 2024-11-02 00:55:45 +07:00
parent 81daab1f4d
commit cf1c20a979
3 changed files with 10 additions and 10 deletions

View File

@ -28,7 +28,7 @@ import { UpdateExecutor } from './executors/update.executor';
import { ControllerOption } from './interfaces/controller/controller.option';
import { ISkeletonCRUDController } from './interfaces/controller/skeleton-crud.controller.interface';
class SkeletonCRUDController implements ISkeletonCRUDController {
export class SkeletonCRUDController implements ISkeletonCRUDController {
constructor(
@Inject(CREATE_PROCESS)
public readonly createProcess,
@ -83,10 +83,10 @@ class SkeletonCRUDController implements ISkeletonCRUDController {
// - Correct me if I wrong. I already read the main repository of NestJS and they use Reflect for passing some metadata ( I know how to do it ) but... it still not possible for dynamic unique identifier
// Known issue:
// - OpenAPI ( Swagger ) cannot read any decorator inside this
export const AutoCRUDController = (options?: ControllerOption): any => {
export const CustomCRUDController = (options?: ControllerOption): any => {
const uniqueIdentifier = `${options?.uniqueIdentifier ?? 'id'}`;
class CRUDController extends SkeletonCRUDController {
class WrapperCRUDController extends SkeletonCRUDController {
@Post()
async create(@Body() body): Promise<any> {
return await super.create(body);
@ -119,5 +119,5 @@ export const AutoCRUDController = (options?: ControllerOption): any => {
}
}
return CRUDController;
return WrapperCRUDController;
};

View File

@ -1,5 +1,7 @@
import { AutoCRUDController } from '@aditama-labs/nest-autocrud/skeleton';
import { CustomCRUDController } from '@aditama-labs/nest-autocrud/skeleton';
import { Controller } from '@nestjs/common';
@Controller('example/custom')
export class CustomController extends AutoCRUDController() {}
export class CustomController extends CustomCRUDController({
uniqueIdentifier: 'username',
}) {}

View File

@ -1,7 +1,5 @@
import { Controller } from '@nestjs/common';
import { AutoCRUDController } from 'libs';
import { SkeletonCRUDController } from 'libs';
@Controller('example/simple')
export class SimpleController extends AutoCRUDController({
uniqueIdentifier: 'username',
}) {}
export class SimpleController extends SkeletonCRUDController {}