Coder Social home page Coder Social logo

Express 5 Support? about bull-monitor HOT 12 CLOSED

s-r-x avatar s-r-x commented on August 28, 2024
Express 5 Support?

from bull-monitor.

Comments (12)

s-r-x avatar s-r-x commented on August 28, 2024 1

@robincsamuel hello, looks like apollo-server-express doesn't support express 5 (and it's still in alpha btw) so i'm closing this for now

from bull-monitor.

robincsamuel avatar robincsamuel commented on August 28, 2024 1

I tried to debug the issue and figured out the root cause. It works fine if I pass bodyParserConfig: false to the applyMiddleware method (source). However, I don't see a way to pass this config via bull monitor.

@s-r-x Any idea?

from bull-monitor.

robincsamuel avatar robincsamuel commented on August 28, 2024

It's currently in beta, fyi :)

from bull-monitor.

s-r-x avatar s-r-x commented on August 28, 2024

that's cool

from bull-monitor.

robincsamuel avatar robincsamuel commented on August 28, 2024

Adding a middleware like this fixes the issue since body-parser checks for req._body to see if it's already parsed and skips parsing in that case.

router.post('/queues/graphql', (req, res, next) => {
      req['_body'] = true;
      return next();
});

I think it'd be great if we can pass the Apollo Server/applyMiddleware options via bull monitor configuration. I'd be happy to raise a PR if you think that's a good idea :)

from bull-monitor.

s-r-x avatar s-r-x commented on August 28, 2024

@robincsamuel n1. I think we can add some config to the init method with something like express5: boolean, and tweak bodyparserconfig based on that. wdyt?

from bull-monitor.

robincsamuel avatar robincsamuel commented on August 28, 2024

Yeah, that'd work. But I think accepting the apollo server's acceptMiddleware options would be a more robust solution. Because that'd probably be helpful in many other cases where someone can pass in a custom body parser configuration or even cors configuration.

from bull-monitor.

s-r-x avatar s-r-x commented on August 28, 2024

I don't want to let the library users to deal with any internal dependency (like apollo server) directly, so let's stick with some abstraction for now

from bull-monitor.

robincsamuel avatar robincsamuel commented on August 28, 2024

Okay, that makes sense. What about passing a more generic option like disableBodyParser and disableCors? I think a flag based on the express version may become irrelevant in the future or will end up adding more flags.

Or maybe, we can detect the express version and handle this without a flag.

from bull-monitor.

s-r-x avatar s-r-x commented on August 28, 2024

sounds good

from bull-monitor.

robincsamuel avatar robincsamuel commented on August 28, 2024

so, which method do you think is the best? disableBodyParser flag or detect the express version and handle based on that?

from bull-monitor.

s-r-x avatar s-r-x commented on August 28, 2024

both are fine, do whatever you think fits the best

from bull-monitor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.