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: add customize content type parsers for api plugin #10449

Conversation

scott1028
Copy link
Contributor

@scott1028 scott1028 commented Apr 13, 2024

This PR allows users to extend supported contentType for native API plugin.
I follow https://redwoodjs.com/docs/docker#using-the-server-file, but it doesn't work.

    ...
  await server.register(redwoodFastifyAPI, {          <-- work after remove "await"
    redwood: {
      apiRootPath,
      fastGlobOptions: {
        ignore: ['**/dist/functions/graphql.js'],
      },
    },
  })
   ...

  // This doesn't work after a "await server.register(...)"
  server.addContentTypeParser('text/csv', { parseAs: 'string' }, (request, body, done) => {
    const csvData = body.split('\n').map(row => row.split(','))
    done(null, csvData)
  })

@scott1028 scott1028 force-pushed the add-fastify-custom-add-content-type-parsers branch 3 times, most recently from cd7825f to 56abbb8 Compare April 13, 2024 03:25
@scott1028 scott1028 changed the title WIP: feat: add customize content type parsers for api plugin feat: add customize content type parsers for api plugin Apr 13, 2024
@scott1028 scott1028 closed this Apr 13, 2024
@scott1028 scott1028 reopened this Apr 13, 2024
@scott1028 scott1028 changed the title feat: add customize content type parsers for api plugin WIP: feat: add customize content type parsers for api plugin Apr 13, 2024
@scott1028 scott1028 changed the title WIP: feat: add customize content type parsers for api plugin feat: add customize content type parsers for api plugin Apr 13, 2024
@scott1028 scott1028 force-pushed the add-fastify-custom-add-content-type-parsers branch 2 times, most recently from f5d6234 to f609745 Compare April 14, 2024 16:51
@scott1028 scott1028 force-pushed the add-fastify-custom-add-content-type-parsers branch from f609745 to ae0e572 Compare April 14, 2024 16:52
@scott1028 scott1028 force-pushed the add-fastify-custom-add-content-type-parsers branch from 60a680e to 7d608a2 Compare April 14, 2024 17:19
@thedavidprice thedavidprice added the contributor-pr Use to automatically add PRs to the "Contributor PRs" Project Board label May 1, 2024
@Tobbe
Copy link
Member

Tobbe commented May 1, 2024

Thanks for your PR @scott1028 I'm sorry no one got back to you sooner. We'll discuss this internally and see who can help move this forward

@scott1028
Copy link
Contributor Author

Thanks for your PR @scott1028 I'm sorry no one got back to you sooner. We'll discuss this internally and see who can help move this forward

Thanks for your reply :)

@Tobbe
Copy link
Member

Tobbe commented May 2, 2024

@scott1028 I found someone who can look into this. He's busy with other things right now, but will get to this when he has some more time available

@Josh-Walker-GM
Copy link
Collaborator

Hey @scott1028 👋 Again sorry for the radio silence on this. I'll get to this one in the next day or two

@scott1028
Copy link
Contributor Author

Hey @scott1028 👋 Again sorry for the radio silence on this. I'll get to this one in the next day or two

updated test.

@Tobbe Tobbe added this to the next-release milestone May 10, 2024
@Tobbe Tobbe added the release:feature This PR introduces a new feature label May 10, 2024
@Tobbe
Copy link
Member

Tobbe commented May 11, 2024

@scott1028 Thanks for your effort on this PR!

We've been discussing this PR internally and have a couple of things I wanted to bring up.

  1. We decided we wanted to explore some alternative ways of implementing this.

  2. We think the naming of the parameter could benefit from some additional thought. Could you please help us with some alternative names? Something that makes it more clear what it is, what it does and how it's supposed to be used.

@scott1028
Copy link
Contributor Author

scott1028 commented May 11, 2024

@Tobbe Thanks for reply.

  1. We decided we wanted to explore some alternative ways of implementing this.

Need I work on this PR if you guys want to implement the same somehow?

  1. We think the naming of the parameter could benefit from some additional thought. Could you please help us with some alternative names? Something that makes it more clear what it is, what it does and how it's supposed to be used.

hmm, I will name it something like preCustomizeAPI, customizeAPI etc, because it's executed before await server.register(redwoodFastifyAPI, .... I just want expose a interface for developer to mutate the fasitfy instance.

@Tobbe
Copy link
Member

Tobbe commented May 11, 2024

Need I work on this PR if you guys want to implement the same somehow?

No, nothing for you to do right now 🙂 We'll get back to you with how to move forward next week

@Josh-Walker-GM
Copy link
Collaborator

Sorry it's take me longer than expected to get to this. I'm going to look through this now. One thing that might help me understand better is where you had been planing on using this additional content parser within your project?

@Josh-Walker-GM
Copy link
Collaborator

@scott1028 and @Tobbe - I didn't have permission to push to your fork @scott1028 so I had to open a new PR in the redwood repo: #10573. This uses your original approach but just renames and moves things around a little.

I'm happy with this approach until we decide we need to rework things in a more destructive way. @Tobbe might have naming or other decisions to make but I'd love to know what you think @scott1028 if this is okay and works for your problem?

@scott1028
Copy link
Contributor Author

Sorry it's take me longer than expected to get to this. I'm going to look through this now. One thing that might help me understand better is where you had been planing on using this additional content parser within your project?

Yes. That's what I found the problem and I want to resolve after I surveyed fastify. :)

@scott1028
Copy link
Contributor Author

I'm happy with this approach until we decide we need to rework things in a more destructive way. @Tobbe might have naming or other decisions to make but I'd love to know what you think @scott1028 if this is okay and works for your problem?

It's great and works for me. Thanks.

@dthyresson
Copy link
Contributor

@Josh-Walker-GM can we close this in favor of your PR?

@scott1028
Copy link
Contributor Author

scott1028 commented May 22, 2024

@Josh-Walker-GM can we close this in favor of your PR?

yes. I think we can just use #10573

@scott1028
Copy link
Contributor Author

use #10573

@scott1028 scott1028 closed this May 22, 2024
Josh-Walker-GM added a commit that referenced this pull request Jun 5, 2024
Alterations to #10449

---------

Co-authored-by: scott1028 <mic1028002@gmail.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: David Thyresson <dthyresson@gmail.com>
Josh-Walker-GM added a commit that referenced this pull request Jun 6, 2024
Alterations to #10449

---------

Co-authored-by: scott1028 <mic1028002@gmail.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: David Thyresson <dthyresson@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor-pr Use to automatically add PRs to the "Contributor PRs" Project Board release:feature This PR introduces a new feature
Projects
Archived in project
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants