Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused fields from API Responses #187

Open
chavda-bhavik opened this issue Feb 7, 2023 · 3 comments
Open

Remove unused fields from API Responses #187

chavda-bhavik opened this issue Feb 7, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chavda-bhavik
Copy link
Collaborator

chavda-bhavik commented Feb 7, 2023

Is your feature request related to a problem? Please describe.
It seems obvious that the createdAt, updatedAt, and __v fields are not used anywhere on the front end. so we can remove them from API responses.

Describe the solution you'd like

  1. Add an Exclude decorator to an entity, like,
import { Exclude } from 'class-transformer';
export class MyEntity {
  ...
  @Exclude()
  createdAt: Date;
  @Exclude()
  updatedAt: Date;
  @Exclude()
  __v?: number;
}
  1. Add __v in the SchemaDocument,
interface IMyDocument extends MyEntity, Document {
  _id: never;
  __v: never;
}
  1. In the controller apply the ClassSerializerInterceptor interceptor, like,
import { Body, ClassSerializerInterceptor, UseInterceptors } from '@nestjs/common';
...

@UseInterceptors(ClassSerializerInterceptor)
export class MyController {
  ...
}
  1. Build dal lib by running pnpm build:dal.
  2. Test respective API is sending the correct response.
@chavda-bhavik chavda-bhavik added enhancement New feature or request good first issue Good for newcomers labels Feb 7, 2023
@SamantaTarun
Copy link

I would like to work on this issue. Please assign this issue to me.

@chavda-bhavik
Copy link
Collaborator Author

chavda-bhavik commented Feb 8, 2023

Sure @tarunsamanta2k20 Here is the list of entities & controllers you would like to apply this facility,

  1. ColumnEntity and ColumnController
  2. MappingEntity and MappingController
  3. ProjectEntity and ProjectController
  4. TemplateEntity and TemplateController
  5. UploadEntity and UploadController

Entites are inside the libs/dal/src/repositories folder and Controllers are inside the apps/api/src/app folder. And you can check this guide to setup Impler locally.

Let me know if you need any help. 😃

@chavda-bhavik
Copy link
Collaborator Author

@tarunsamanta2k20 Any update on this issue or do you need any help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants