I see that you are using nodejs.
I believe that the best way to check the input parameters is to approve. NodeJS has a built-in simple approval module: http://nodejs.org/api/assert.html
And use it, for example, as follows:
var assert = require('assert'); // ... function myFunction (param) { assert(param, 'please pass param'); // ... }
In a test environment, you can do this as follows:
require('assert')(process.env.setting, 'please set the SETTING environmental variable');
Or:
;(function (a) { a(process.env.setting, 'please set the SETTING environmental variable'); a(process.env.port, 'please set the PORT environmental variable'); }(require('assert')));
Alex Yaroshevich
source share