New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@myndzi/app-framework

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@myndzi/app-framework - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

lib/bind-signals.js

28

lib/configure.js
'use strict';
var convict = require('convict'),
extendConvict = require('./extend-convict'),
cUtils = require('./convict-utils'),
PATH = require('path');

@@ -21,9 +21,9 @@

}
if (typeof schema === 'function') {
schema = schema(app, convict);
}
var conf = extendConvict(app.config, schema);
var conf = cUtils.extendConvict(app.config, schema);
var env = conf.get('app.env');

@@ -35,5 +35,5 @@ var appName = conf.get('app.name');

}
if (app.log) { app.log.debug('Loading config...'); }
[ PATH.join(cfgPath, 'all.js'),

@@ -56,13 +56,17 @@ PATH.join(cfgPath, env + '.js'),

});
// reload the explicitly specified config components (highest priority)
if (config && typeof config === 'object') { conf.load(config); }
if (config && typeof config === 'object') {
// convict overrides anything loaded this way with environment vars/arguments! we have to do it the hard way...
// conf.load(config);
cUtils.load(conf, config);
}
// throws if errors -> rejected promise by Promise.method wrapper
conf.validate();
app.config = conf;
app.emit('configure');
return app;
});

@@ -14,7 +14,7 @@ 'use strict';

opts.app = opts.app || 'app';
var app = express();
require('./pre-config')(app, config);
if (app.config.get('log.level') === 'none') {

@@ -26,6 +26,4 @@ require('./null-logger')(app);

var boundSignals = false;
function _SIGINT() { app.shutdown('Got SIGINT'); }
function _SIGTERM() { app.shutdown('Got SIGTERM'); }
require('./bind-signals')(app);
require('./live-config')(app);

@@ -35,3 +33,3 @@ function reconfigure() {

app.version = app.config.get('app.version');
// honestly i don't know why i thought it would be a good idea to respond to reconfiguring

@@ -44,24 +42,13 @@ // the app root. this should probably be removed somewhere along the line.

app.path = function (path) { return PATH.join(app.root, opts.app, path); };
// bind signals for exiting explicitly, helps when running under Docker
if (app.config.get('app.bindSignals')) {
if (!boundSignals) {
process.on('SIGINT', _SIGINT);
process.on('SIGTERM', _SIGTERM);
boundSignals = true;
}
} else {
process.removeListener('SIGINT', _SIGINT);
process.removeListener('SIGTERM', _SIGTERM);
}
app.emit('reconfigured');
}
app.on('configure', reconfigure);
reconfigure();
app.on('loaded', function () {
app.log.debug(app.config.get(), 'Resolved config:');
});
require('./listener')(app);

@@ -71,3 +58,3 @@ app.on('listening', function (address, port, env) {

});
require('./shutdown')(app);

@@ -79,3 +66,3 @@ var sd_start = Date.now();

timeout = (isNaN(parseInt(timeout, 10)) ? '(no timeout)' : '(timeout: ' + timeout + 'ms)');
app.log.info('%s: %s %s', type, msg, timeout);

@@ -91,3 +78,3 @@ });

});
var load = require('./load-files');

@@ -94,0 +81,0 @@ app.loadFiles = load;

@@ -7,3 +7,3 @@ 'use strict';

var convict = require('convict'),
extendConvict = require('./extend-convict');
cUtils = require('./convict-utils');

@@ -14,8 +14,8 @@ // sets up a config environment for components that load before the schema proper

config = config || { };
config.app = config.app || { };
config.log = config.log || { };
// deal with passing flat options / legacy keys
if (config.env) {

@@ -37,7 +37,7 @@ config.app.env = config.app.env || config.env;

}
var conf = convict({ });
conf.load(config);
conf = extendConvict(conf, {
cUtils.load(conf, config);
conf = cUtils.extendConvict(conf, {
app: {

@@ -65,4 +65,4 @@ bindSignals: {

});
conf = extendConvict(conf, {
conf = cUtils.extendConvict(conf, {
app: {

@@ -88,5 +88,5 @@ root: {

});
var appRoot = conf.get('app.root');
try {

@@ -110,4 +110,4 @@ var stat = fs.statSync(appRoot);

}
conf = extendConvict(conf, {
conf = cUtils.extendConvict(conf, {
app: {

@@ -149,4 +149,4 @@ name: {

});
app.config = conf;
};

@@ -8,21 +8,24 @@ 'use strict';

var EXIT_CODES = require('./exit-codes');
app._shutdownPromise = null;
app.restart = function (msg, timeout) { return app.shutdown(EXIT_CODES.RELOAD, msg, timeout); };
app.shutdown = function (/*[code], [msg], [timeout]*/) { // jshint maxstatements: 22, maxcomplexity: 8
app.shutdown = function (/*[code], [msg], [timeout]*/) { // jshint maxstatements: 25, maxcomplexity: 8
if (app._shutdownPromise) { return app._shutdownPromise; }
var i = arguments.length, args = new Array(i);
while (i--) { args[i] = arguments[i]; }
var code = EXIT_CODES.UNKNOWN, msg = 'unknown', timeout = null;
if (typeof args[0] === 'number') { code = args.shift(); }
if (typeof args[0] !== 'number') { msg = args.shift(); }
if (typeof args[0] === 'number') { timeout = args.shift(); }
if (timeout === null) { timeout = app.config.get('app.shutdownTimeout') || null; }
app.emit('before shutdown', code, msg, timeout);
var promises = [ ],
listeners = app.listeners('shutdown');
function makePromise(arg) {

@@ -47,7 +50,7 @@ if (typeof stream.once === 'function') {

}
// allow events to register async completion
listeners.forEach(function (handler) {
var ret, err;
try {

@@ -63,3 +66,3 @@ ret = handler.call(app, function await(arg) {

else { err = e; }
err.message = 'Shutdown handler threw: ' + err.message;

@@ -73,3 +76,3 @@ promises.push(Promise.reject(err));

}));
var shutdownErrors = cleanupHandlers.then(function (results) {

@@ -82,4 +85,4 @@ return results.filter(function (promise) {

});
return new Promise(function (resolve) {
app._shutdownPromise = new Promise(function (resolve) {
var timer;

@@ -101,3 +104,3 @@ if (!isNaN(parseInt(timeout, 10))) {

}
result = {

@@ -107,7 +110,8 @@ code: code,

};
app.emit('after shutdown', result);
return result.code;
});
return app._shutdownPromise;
};
};
{
"name": "@myndzi/app-framework",
"version": "1.4.4",
"version": "1.4.5",
"description": "Config and logging framework for Node.js applications",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

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