<commit_before>var express = require('express')
var bodyParser = require('body-parser')
var cors = require('cors')
var http = require('http')

function bpmRoute () {
  var bpm = new express.Router()
  bpm.use(cors())
  bpm.use(bodyParser.json())


  bpm.post('/startProcess', function (req, res) {
    // Prepare BPM REST call
    var method = 'POST';
    var path = '/business-central/rest/runtime/' + process.env.BPM_PROCESS_DEPLOYMENTID + '/process/' + process.env.BPM_PROCESS_PROCESSDEFID + '/start?' + createQueryParameterMapString(req.body.params);
    var options = getCredentialsForBpmConnection(req,method,path);
    // Execute BPM REST call
    var bpmHttpReq = http.request(options, function (bpmHttpRes) {
      var response = '';
      console.log('STATUS: ' + bpmHttpRes.statusCode)
      console.log('HEADERS: ' + JSON.stringify(bpmHttpRes.headers))
      bpmHttpRes.setEncoding('utf8')
      bpmHttpRes.on('data', function (chunk) {
        response += chunk;
      })
      bpmHttpRes.on('end', function () {
        res.send(response);
      })
    })
    bpmHttpReq.on('error', function (e) {
      res.json({error: 'Problem with request:' + e.message, reqbody: options})
    })
    bpmHttpReq.end()
  })

  bpm.post('/getProcess', function (req, res) {
    // Prepare BPM REST call
    var method = 'GET';
    var path = '/business-central/rest/runtime/' + process.env.BPM_PROCESS_DEPLOYMENTID + '/process/' + process.env.BPM_PROCESS_PROCESSDEFID;
    var options = getCredentialsForBpmConnection(req,method,path);
    // Execute BPM REST call
    var bpmHttpReq = http.request(options, function (bpmHttpRes) {
      var response = '';
      console.log('STATUS: ' + bpmHttpRes.statusCode)
      console.log('HEADERS: ' + JSON.stringify(bpmHttpRes.headers))
      bpmHttpRes.setEncoding('utf8')
      bpmHttpRes.on('data', function (chunk) {
        response += chunk;
      })
      bpmHttpRes.on('end', function () {
        res.send(response);
      })
    })
    bpmHttpReq.on('error', function (e) {
      res.json({error: 'Problem with request:' + e.message, reqbody: options})
    })
    bpmHttpReq.end()
  })

  bpm.post('/testRequest', function(req, res) {
    // Prepare BPM REST call
    var method = 'GET';
    var path = '/business-central/rest';
    var options = getCredentialsForBpmConnection(req,method,path);
    // Execute BPM REST call
    var bpmHttpReq = http.request(options, function (bpmHttpRes) {<commit_msg>Fixed methodname and path to mBaaS function<commit_after>var express = require('express')
var bodyParser = require('body-parser')
var cors = require('cors')
var http = require('http')

function bpmRoute () {
  var bpm = new express.Router()
  bpm.use(cors())
  bpm.use(bodyParser.json())


  bpm.post('/startProcess', function (req, res) {
    // Prepare BPM REST call
    var method = 'POST';
    var path = '/business-central/rest/runtime/' + process.env.BPM_PROCESS_DEPLOYMENTID + '/process/' + process.env.BPM_PROCESS_PROCESSDEFID + '/start?' + createQueryParameterMapString(req.body.params);
    var options = getCredentialsForBpmConnection(req,method,path);
    // Execute BPM REST call
    var bpmHttpReq = http.request(options, function (bpmHttpRes) {
      var response = '';
      console.log('STATUS: ' + bpmHttpRes.statusCode)
      console.log('HEADERS: ' + JSON.stringify(bpmHttpRes.headers))
      bpmHttpRes.setEncoding('utf8')
      bpmHttpRes.on('data', function (chunk) {
        response += chunk;
      })
      bpmHttpRes.on('end', function () {
        res.send(response);
      })
    })
    bpmHttpReq.on('error', function (e) {
      res.json({error: 'Problem with request:' + e.message, reqbody: options})
    })
    bpmHttpReq.end()
  })

  bpm.post('/getProcessInstance', function (req, res) {
    // Prepare BPM REST call
    var method = 'GET';
    var path = '/business-central/rest/runtime/' + process.env.BPM_PROCESS_DEPLOYMENTID + '/process/' + process.env.BPM_PROCESS_PROCESSDEFID;
    var options = getCredentialsForBpmConnection(req,method,path);
    // Execute BPM REST call
    var bpmHttpReq = http.request(options, function (bpmHttpRes) {
      var response = '';
      console.log('STATUS: ' + bpmHttpRes.statusCode)
      console.log('HEADERS: ' + JSON.stringify(bpmHttpRes.headers))
      bpmHttpRes.setEncoding('utf8')
      bpmHttpRes.on('data', function (chunk) {
        response += chunk;
      })
      bpmHttpRes.on('end', function () {
        res.send(response);
      })
    })
    bpmHttpReq.on('error', function (e) {
      res.json({error: 'Problem with request:' + e.message, reqbody: options})
    })
    bpmHttpReq.end()
  })

  bpm.post('/testRequest', function(req, res) {
    // Prepare BPM REST call
    var method = 'GET';
    var path = '/business-central/rest';
    var options = getCredentialsForBpmConnection(req,method,path);
    // Execute BPM REST call
    var bpmHttpReq = http.request(options, function (bpmHttpRes) {
{'fraction_non_alphanumeric': 0.14638091386979377, 'fraction_numerical': 0.0008087343307723412, 'mean_word_length': 3.2831168831168833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6286388', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1605, 'n_words': 320}