klerick / nestjs-json-api

56 stars 10 forks source link

[Question] How can I overrided the resource name? #27

Closed kun391 closed 1 year ago

kun391 commented 1 year ago

Hi,

I have an entity class name User, now, the resource name generated is /user/ So if I want to generate to /users, I must rename the class name to Users

Screen Shot 2023-01-01 at 10 24 06

Have any options to override the resource to users with the entity class name User on your package @klerick?

Thanks

klerick commented 1 year ago

You can not change name of route. I don't have plane for add this feature

Mites-G commented 1 year ago

@klerick Would you re-consider accepting this feature request if I try to come up with a solution for it and then open a PR?

I'm thinking about an option on our JsonApi decorator where you can overwrite what goes into the Controller decorator.

IE:

@JsonApi(User, {
  requiredSelectField: false,
  overrideEndpoint: 'users'
})
export class UserController extends JsonBaseController<User> {}

So we keep everything as is today but we would just have the option to change the endpoint path.

klerick commented 1 year ago

@Mites-G I have viewed source code, so now I believe will need to do minimal changes for this feature.

I think, it will be like that:

Mites-G commented 1 year ago

Awesome, @klerick. I was looking further into that and we reached the same conclusion.

Here's the pull request: https://github.com/klerick/nestjs-json-api/pull/43

Any more suggestions appreciated.

klerick commented 1 year ago

today I having weekend)but tomorrow, I will approve your pr and create new version.

Mites-G commented 1 year ago

Enjoy your weekend!

github-actions[bot] commented 1 year ago

:tada: This issue is included in version json-api-nestjs@4.2.11 :tada:

The release is available on GitHub release

github-actions[bot] commented 1 year ago

:tada: This issue is included in version json-api-nestjs-sdk@5.0.0 :tada:

The release is available on GitHub release