Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/htdocs/w008e48d/sigadev/wordpress/wp-includes/locale.php on line 375

Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/w008e48d/sigadev/wordpress/wp-includes/locale.php:375) in /www/htdocs/w008e48d/sigadev/wordpress/wp-includes/feed-rss2.php on line 8
Things I do http://sigadev.com A blog like 1000 others (german/english) (c) Johann Blauensteiner Fri, 07 Aug 2015 11:01:46 +0000 en-US hourly 1 https://wordpress.org/?v=3.9.27 Configuration in Node.js http://sigadev.com/2014/08/07/configuration-in-node-js/ http://sigadev.com/2014/08/07/configuration-in-node-js/#comments Thu, 07 Aug 2014 09:32:43 +0000 http://sigadev.com/?p=19 UsingĀ  configuration settings is quite easy in Node. Just use a plain old object.

var env = process.env.NODE_ENV || 'development';
var config = {
  development: {
    key:'value'
  },
  test: {
    key:'value'
  },
  production: {
    ...
  }
}
module.exports = config[env];

var config = require('./config');

Or store the configuration as JSON-File:

{
  "development": {
    "key":"value"
  },
  "test": {
    "key":"value"
  },
  "production": {
    ...
  }
}

var env = process.env.NODE_ENV || 'development';
var config = require('./config')[env];

BUT…. It’s not always that easy.

Typical requirements are:

  • multiple config files (with hierarchical dependencies)
  • config needs to vary based on running environment (development, production)
  • use environment variables
  • use arguments
  • including credentials and sensitive information in source can be problematic

Take a closer look at NPM and you realize there are many packages.

After reading a few posts I decided to focus in convict and nconf.

I started with nconf.

Description from their website:

Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging. it is designed to be a simple key-value store with support for both local and remote storage

nconf makes it easier to handle configuration files but the advantages are not as many as I expected. Ok, it’s better using a well tested module with community support than doing it myself but nconf was not able to convince me.

So I moved on to convict.

After spending 5 minutes for the documentation it was clear, it is the right thing because it has a validation feature.

Before you can use validation, you have to prepare a schema. In order to help detect misconfiguration, convict allows you to define a format for each setting:

  • Type information
  • Default values
  • values from environmental variables or command-line arguments
  • Documentation (nice feature, so even after 10 months you still know what a setting is good for :-) )

So due to its validation feature, illegal config values are detected and environmental variables can be mapped to any configuration key without coding.

So I stay with convict.

photo credit: JaulaDeArdilla via photopin cc

 

]]>
http://sigadev.com/2014/08/07/configuration-in-node-js/feed/ 0
UI, where are you? http://sigadev.com/2014/07/23/ui-where-are-you/ http://sigadev.com/2014/07/23/ui-where-are-you/#comments Wed, 23 Jul 2014 13:15:01 +0000 http://sigadev.com/?p=12 For my current Node.js project I need a HTML-UI-Framework, which offers:

  • Drag&Drop components (
  • Handle SVG
  • A lot of components
  • “Help System” (F1) included for components
  • I18N, L10N (yes I do Java too)

Ok, it sounds like a wishlist for Christmas

Of course, JQuery UI is an option, but I want to spend some time for new alternatives “New” for me

So I start evaluating…

JQuery EasyUI

W2UI

photo credit: NathanaelB via photopin cc

]]>
http://sigadev.com/2014/07/23/ui-where-are-you/feed/ 0