Socket
Socket
Sign inDemoInstall

widget-loader

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

widget-loader - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

npm-shrinkwrap.json

19

lib/loader.js
"use strict";
const _ = require('lodash');
const sequence = require('when/sequence');
const path = require('path');

@@ -9,2 +11,4 @@ const fs = require('fs');

module.exports = function (App, opts) {

@@ -30,3 +34,3 @@

// Check for an actual class, catch just use whatever was returned
if (typeof AppClass === 'function') {
if (_.isFunction(AppClass)) {
app = new AppClass();

@@ -112,5 +116,5 @@ } else {

function sortWidgets (widgetCollection) {
let widgetPositions = Object.keys(widgetCollection);
let widgetPositions = _.keys(widgetCollection);
widgetPositions.forEach(function (key) {
_.each(widgetPositions, function (key) {
widgetCollection[key].sort(function (obj1, obj2) {

@@ -138,3 +142,3 @@ return obj1.config.order - obj2.config.order;

// filter and get widgets for only this specific page
filteredWidgets = WidgetCollection.filter(function (widget) {
filteredWidgets = _.filter(WidgetCollection, function (widget) {
return widget.config.active && matchRoute(widget.config.routes, req.path);

@@ -144,3 +148,3 @@ });

// execute widget request and extract return data
widgetOps = filteredWidgets.map(function (widget) {
widgetOps = _.map(filteredWidgets, function (widget) {
return function () {

@@ -161,3 +165,3 @@ return widget.exec(App)

if (!Array.isArray(CurrentWidgetCollection[position])) {
if (!_.isArray(CurrentWidgetCollection[position])) {
CurrentWidgetCollection[position] = [];

@@ -173,2 +177,3 @@ }

next(error);
//req.flash('error', { msg: errory.message });
});

@@ -179,3 +184,3 @@ };

// when widgets are loaded, continue
Promise.all(widgetOps)
sequence(widgetOps)
.then(function () {

@@ -182,0 +187,0 @@ //console.timeEnd('middlware');

{
"name": "widget-loader",
"version": "1.0.0",
"version": "1.0.1",
"description": "Widget loader for WidGet CMS",

@@ -28,3 +28,5 @@ "main": "index.js",

"dependencies": {
"ghost-sandbox": "^1.0.0"
"ghost-sandbox": "^1.0.1",
"lodash": "^4.16.4",
"when": "^3.7.7"
},

@@ -36,4 +38,4 @@ "devDependencies": {

"supertest": "^1.2.0",
"mocha": "^2.5.3"
"mocha": "^3.1.0"
}
}

@@ -47,5 +47,16 @@ "use strict";

.get('/')
.expect(200, done);
.expect('Content-Type', /json/)
.expect(200)
.end(function(err, res) {
if (err) {
return done(err);
}
Object.keys(res.body).length.should.be.gt(0);
done()
});;
});
});
});
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