mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-24 04:46:21 +00:00
feat: rename AutoCRUDController to CustomCRUDController
This commit is contained in:
parent
81daab1f4d
commit
cf1c20a979
@ -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;
|
||||
};
|
||||
|
@ -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',
|
||||
}) {}
|
||||
|
@ -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 {}
|
||||
|
Loading…
Reference in New Issue
Block a user