Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.use(function (req, res, next) {
var context = app.createContext({
req: req, // The fetchr plugin depends on this
xhrContext: {
_csrf: req.csrfToken() // Make sure all XHR requests have the CSRF token
}
});
debug('Executing showChat action');
if ('0' === req.query.load) {
renderPage(req, res, context);
} else {
context.executeAction(navigateAction, { url: req.url, type: 'pageload' }, function (err) {
if (err) {
if (err.statusCode && err.statusCode === 404) {
next();
} else {
next(err);
}
return;
}
renderPage(req, res, context);
});
}
});
context.service.delete('projects', payload, {}, function(error, response) {
if (error) {
context.dispatch('DELETE_PROJECT_FAILURE', payload);
done();
return;
}
context.dispatch('DELETE_PROJECT_SUCCESS', response.repository);
if ('undefined' !== typeof window && 'undefined' !== typeof io) {
var socket = io();
socket.emit('leave', { repository: payload.project.repository } );
}
navigateAction(context, {
url: '/projects'
}, done);
});
};
.then(function () {
debug('Executing navigate action');
return context.executeAction(navigateAction, {
url: req.url
});
})
.then(null, function (reason) {
handleSwipe: function (index) {
var pages = this.props.pages;
if (pages[this.props.pageName].order !== index) {
var nextPageName = Object.keys(pages).filter(function (page) {
return pages[page].order === index && pages[page].mainNav;
})[0];
this.context.executeAction(navigateAction, {
name: nextPageName,
url: pages[nextPageName].path
});
}
},
context.service.create('projects', payload, {}, function(error, response) {
if (error) {
context.dispatch('CREATE_PROJECT_FAILURE', payload);
done();
return;
}
context.dispatch('CREATE_PROJECT_SUCCESS', response.project);
navigate(context, {
url: '/projects/' + payload.repository
}, function() {
context.service.create('builds', payload, {}, function() {
done();
});
});
});
};
if ('header' === req.session.loginType) {
context.executeAction(updateLoginHeaderStatus, req.session.errorNum);
} else {
req.url = '/login';
context.executeAction(updateLoginFormStatus, req.session.errorNum);
}
req.session.errorNum = 0;
}
debug('Setting Csrf token to ' + req.csrfToken());
context.executeAction(updateCsrfToken, req.csrfToken());
debug('Executing navigate action');
context.executeAction(navigateAction, {
url: req.url,
method: req.method
}, function (err) {
if (err) {
if (err.status && err.status === 404) {
next();
} else {
next(err);
}
return;
}
if (req.url.match(/^\/blog\/.+$/i)) {
context.executeAction(readPost, req.url.replace(/^\/blog\/(.+)\/?$/i, '$1'), function() {
debug('Exposing context state');
var exposed = 'window.App=' + serialize(app.dehydrate(context)) + ';';