const { exec } = require('child_process')

module.exports = (server, db) => {
    return {
        index: (req, res, next) => {
            let hash = req.body.hash
            console.log(`imprimindo pedido com hash '${hash}'`)
            exec(`cd java-printer && java -jar java-printer.jar ${hash}`, (err, stdout, stderr) => {
                console.log(stdout)
            })
            res.send('imprimindo comanda')
            next()
        }
    }
}
