module.exports = (puppeteer) => {
  return async (req, res, next) => {
    
    const browser = await puppeteer.launch({
      executablePath: '/usr/bin/google-chrome',
      args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu'],
      ignoreDefaultArgs: ['--disable-extensions'],
      headless: 'true'
    });

    req.puppeteerBrowser = browser;
    next();
  }
}