Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const express = require('express');
const router = express.Router();
const fs = require("fs-extra");
const models = require('../models/');
const entity_helper = require('../utils/entity_helper');
const upload = require('multer')().single('file');
const moment = require('moment');
const globalConf = require('../config/global');
// *********** Cloud function *************
// This method receives and processes situation and send the dump of Cloud DB to the tablet
// *****************************************
router.post('/situation', function(req, res) {
// Operation can take some time, remove timeout of response
res.setTimeout(0);
function executeJournal(journal) {
// Start MYSQL transaction.
// If anything goes wrong during the execution of the journal, all modifications will be rolled back.
// It's important not to break the `promise chain` by returning each promise to its parent to keep transaction open
return models.sequelize.transaction(function(transac) {