As said in the document, putting all the code in the @Crud() decorator will lose type hints, but we could implement that by building dynamic base classes and then extend them. (just like what I did in my own lib superest)
@Controller('path')
class CrudController<T> extends Crud(
model: { type: MyEntity },
)</* generic types if needed */> {
// using `@Crud()`, we must put `public service: MyCrudService` here, but now
// we could use any param name and could make it private and readonly
constructor(private readonly anyServiceName: MyCrudService) {
super(anyServiceName);
}
// overriding
getOneBase(
@ParsedRequest() req: CrudRequest,
): Promise<T> {
super.getOneBase(req);
// ...
}
}
As said in the document, putting all the code in the
@Crud()
decorator will lose type hints, but we could implement that by building dynamic base classes and then extend them. (just like what I did in my own lib superest)