title: Writing Generic wrapper APIs for backend APIs
body: <p>I have a few backend APIs which starts with /companies .
  Exa. (there are more than 30 APIs)</p>
  
  <p>GET: <a href="https://example.com/api/companies/employee" rel="nofollow noreferrer">https://example.com/api/companies/employee</a> </p>
  
  <p>GET: <a href="https://example.com/api/companies/sites" rel="nofollow noreferrer">https://example.com/api/companies/sites</a> </p>
  
  <p>POST: <a href="https://example.com/api/companies/addNewSite" rel="nofollow noreferrer">https://example.com/api/companies/addNewSite</a> </p>
  
  <p>PUT: <a href="https://example.com/api/companies/updateSite" rel="nofollow noreferrer">https://example.com/api/companies/updateSite</a></p>
  
  <p>I need to pass Authorization header to all these APIs. For that I need to write a wrapper API and use that API to access from the client side.</p>
  
  <p>To achieve this, I understand I need to create different routes for all above APIs in my node.js express application something like this:</p>
  
  <pre><code>app.get("/api/companies/employee, (req, res) =&gt; {
     req.header = {authorization: "Bearer sometoken"};
     const response = await apiHelper.makeRequest("GET", https://example.com/api/companies/sites);
     res.status(200).json(response);
  })
  
  app.post("/api/companies/addNewSite", (req, res) =&gt; {
    ....
  })
  </code></pre>
  
  <p>This way, I need to create wrapper APIs for all 30 different APIs which doesn't seems right.</p>
  
  <p>So, was wondering if there is a better way to create one single wrapper API for all above APIs. </p>