Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
Feature toggling using Expressjs middleware - frontend and backend

My current project is using Node for both frontend and backend and ExpressJS as the middleware.

I have a requirement where I need a feature toggling implementation to introduce some new features in my application. I am using a url parameter, e.g. &featureToggle=true to determine if the code of execution would be the new one or the existing.

Now I have parts in frontend and backend both which need to be changed based on the feature toggle. In the backend I can get the query object separately and extract the url param, similarly also in the frontend module.

Is there a way in which I can use Express to intercept the query param, set a variable value to either true or false based on the feature toggle, and which could be used across both the frontend and backend modules?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

with express you can use req.query which gathers the query string sent in the request. You could pass it like this:

localhost:9000/path?&featureToggle=true

the ? is important it tells express that you are creating a query.

if you then place it into a variable:

const query = req.query

you would get the following output:

{ featureToggle: 'true' }

so as you can see it is returning an object. you can check it like so:

if(req.query.featureToggle === 'true'){
  runSomeCode();
};

or in your case if you want to run some kind of middleware:

router.get('/', (req, res, next) => {
  if(req.query.featureToggle === 'true'){
    return next(toggle)
  }
};
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda