Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

periodicjs.core.controllerhelper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

periodicjs.core.controllerhelper - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

111

lib/controllerhelper.js

@@ -23,3 +23,8 @@ /*

*/
var ControllerHelper = function () {
var logger,appSettings;
var ControllerHelper = function (resources) {
logger = resources.logger;
appSettings = resources.settings;
};

@@ -87,2 +92,106 @@

ControllerHelper.prototype.handleDocumentQueryRender = function (options) {
var res = options.res,
req = options.req,
redirecturl = options.redirecturl,
err = options.err,
callback = options.callback,
responseData = options.responseData;
if (err) {
this.handleDocumentQueryErrorResponse({
res: res,
req: req,
err: err,
callback: callback,
redirecturl: redirecturl
});
}
else {
responseData.periodic = responseData.periodic || {};
responseData.periodic.version = appSettings.version;
responseData.periodic.name = appSettings.name;
responseData.request = {
query: req.query,
params: req.params,
baseurl: req.baseUrl,
originalurl: req.originalUrl,
parsed: req._parsedUrl
};
responseData.flash_messages = req.flash();
if (req.query.format === 'json' || req.params.ext === 'json') {
res.send(responseData);
}
else if (req.query.callback) {
res.jsonp(responseData);
}
else if (options.redirecturl) {
res.redirect(options.redirecturl);
}
else {
res.render(options.renderView, responseData);
}
}
if (callback) {
callback();
}
};
ControllerHelper.prototype.handleDocumentQueryErrorResponse = function (options) {
var err = options.err,
errormessage = (typeof options.err === 'string') ? options.err : options.err.message,
redirecturl = options.redirecturl,
req = options.req,
res = options.res,
callback = options.callback; //,
// errorFlashMessage = (options.errorflash) ? options.errorflash : errormessage;
res.status(400);
logger.error(err.stack);
logger.error(errormessage, req.url);
if (req.query.format === 'json') {
res.send({
'result': 'error',
'data': {
error: errormessage
}
});
}
else {
if (options.errorflash !== false) {
req.flash('error', errormessage);
}
if (callback) {
callback();
}
else if (redirecturl) {
res.redirect(redirecturl);
}
else {
var self = this;
self.getPluginViewDefaultTemplate({
viewname: 'home/error404',
themefileext: appSettings.templatefileextension
},
function (err, templatepath) {
self.handleDocumentQueryRender({
res: res,
req: req,
renderView: templatepath,
responseData: {
pagedata: {
title: 'Not Found'
},
user: req.user,
url: req.url
}
});
}
);
}
}
};
module.exports = ControllerHelper;

2

package.json
{
"name": "periodicjs.core.controllerhelper",
"description": "Customizable CMS platform",
"version": "1.0.0",
"version": "1.0.1",
"main": "index.js",

@@ -6,0 +6,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc