diff --git a/libs/skeleton/src/skeleton-crud.controller.ts b/libs/skeleton/src/skeleton-crud.controller.ts index 6d9447c..c3c4995 100644 --- a/libs/skeleton/src/skeleton-crud.controller.ts +++ b/libs/skeleton/src/skeleton-crud.controller.ts @@ -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 { return await super.create(body); @@ -119,5 +119,5 @@ export const AutoCRUDController = (options?: ControllerOption): any => { } } - return CRUDController; + return WrapperCRUDController; }; diff --git a/src/example/custom/custom.controller.ts b/src/example/custom/custom.controller.ts index 28b6327..7cea223 100644 --- a/src/example/custom/custom.controller.ts +++ b/src/example/custom/custom.controller.ts @@ -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', +}) {} diff --git a/src/example/simple/simple.controller.ts b/src/example/simple/simple.controller.ts index b19bcaa..1da6add 100644 --- a/src/example/simple/simple.controller.ts +++ b/src/example/simple/simple.controller.ts @@ -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 {}