I have an Express js server endpoint with the following directory structure:
- app.js
- node_modules
- package-lock.json
- package.json
- mrz-detection
The mrz-detection directory, contains a node app which I would normally call from the command line like this node run/getMrz.js --file passport.jpg
My app.js looks like this
const { getMrz } = require('./mrz-detection');
const fs = require('fs');
const app = express()
const port = 3000
const bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '10mb', extended: true}));
var passportsArr = [];
app.post('/', function(req, res) {
var passport = req.body;
let buff = new Buffer(passport.data, 'base64');
fs.writeFileSync('passport.png', buff);
// send passport photo to mrz-detection app here
})
app.listen(port, () => console.log(`Mrz detection app listening at http://localhost:${port}`))
I need to call the mrz-detection app from my post route in the app.js
How would I do that?