Skip to content

Commit

Permalink
fix: fixed so that name of extended controller follow original name (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JadenKim-dev committed Jun 4, 2024
1 parent bed53a5 commit e20610c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/exclude-swagger/exclude-swagger-resonse-name.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('exclude swagger > defined name', () => {
expect(routeSet[create].root).toEqual({
method: 'post',
path: '/exclude-swagger',
operationId: 'reservedCreate',
operationId: 'ExcludeSwaggerController_reservedCreate',
summary: "create one to 'Base' Table",
description: "Create an entity in 'Base' Table",
parameters: [],
Expand Down
2 changes: 1 addition & 1 deletion spec/exclude-swagger/exclude-swagger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('exclude swagger by route', () => {
expect(routeSet[create].root).toEqual({
method: 'post',
path: '/exclude-swagger',
operationId: 'reservedCreate',
operationId: 'ExcludeSwaggerController_reservedCreate',
summary: "create one to 'Base' Table",
description: "Create an entity in 'Base' Table",
parameters: [],
Expand Down
4 changes: 3 additions & 1 deletion src/lib/crud.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ export const Crud =
const crudRouteFactory = new CrudRouteFactory(target, options);
crudRouteFactory.init();

return class extends target {
const ValidatedController = class extends target {
constructor(...args: any[]) {
super(...args);
if (!(this.crudService instanceof CrudService)) {
throw new TypeError('controller should include member crudService, which is instance of CrudService');
}
}
};
Object.defineProperty(ValidatedController, 'name', { value: target.name });
return ValidatedController;
};

0 comments on commit e20610c

Please sign in to comment.