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

feat(recipes/front_end): add initial api files #412

Merged
merged 1 commit into from
Sep 9, 2022
Merged

Conversation

ttapia
Copy link
Contributor

@ttapia ttapia commented Aug 26, 2022

Context

It is common that on a generated project one manually adds an api object that wraps axios and camelizes/decamelizes keys from requests/responses.

Changes

  • Create two files that are copied into the generated project.
    • app/javascript/api/index.ts: the api object
    • app/javascript/utils/decamelizer.ts: an implementation of decamelize that doesn't delete the information of a File type object sent in requests.
  • Added a setup_api_client method in the front_end recipe that installs axios and humps and copies the files into the generated project.
  • Tests for the setup_api_client method

@ttapia ttapia requested a review from gmq August 26, 2022 19:25
Copy link
Member

@gmq gmq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se ve bien 💯
Mi única duda es si tal vez valdría la pena agregar un ejemplo explicando como usar ese api/index. O tal vez un comentario en el mismo archivo 🤔

@nicolasguridi
Copy link
Contributor

Vengo a meter la cuchara 🥄 , con un problema que me encontré hoy día:

  1. decamelizeKeys también rompe los objetos de tipo Blob. Aquí una issue en Humps mencionándolo.
  2. camelizeKeys también rompe cosas, o por lo menos los objetos de tipo Blob. Habría que comprobarlo para File.

Me tinca entonces que lo más lógico sería que esta función custom que estamos usando para decamelizar incluya a los Blob y también sirva para camelizar. Qué opinan? @gmq @ttapia

@ttapia
Copy link
Contributor Author

ttapia commented Sep 2, 2022

@gmq @nicolasguridi agregué dos cosas, hice los cambios para resolver el tema que planteó nico, y agregué un ejemplo de uso del objeto api en el index.ts

Copy link
Member

@gmq gmq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@ttapia ttapia merged commit 8d0f887 into master Sep 9, 2022
@ttapia ttapia deleted the feat/add_api_client branch September 9, 2022 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants