Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!