title: Applying best practice to make js file for data access in node app
body: <p>I created file which I am going to use to keep only data access inside:</p>
  
  <pre><code>    const sql = require('mssql');
  
          async function getUsers(config) {
            try {
              let pool = await sql.connect(config);
  
              return await pool.request().query('select * from someTable');
            } catch (err) {}
          }
  
          async function getRoles(config) { ...
          async function updateUser(config) { ...
  
  module.export([
    getUsers,
    getRoles,
    updateUser
  ])
  </code></pre>
  
  <p>All this functions are in one js file and you can see each function receive config object as parameter.<br/>
  I am trying to avoid this and have one pool.<br/>
  But this file is not class it doesn't have constructor or init.<br/>
  And this is aws lambda project in index.js I get config data this is why I am passing config to each function.<br/><br/>
  How I can make this file so I can pass config once and make sure connections are closed?<br/>
  I am confused on how to organise this file using some best practices.</p>